#12561: Python (運氣好就會過(?))


chris2012 (丁小魚)

學校 : 控江中学
編號 : 67347
來源 : [211.21.81.44]
最後登入時間 :
2019-03-05 12:55:39
d430. 第二題: 計算字數 (count) -- 92學年度北基區資訊學科能力競賽 | From: [180.217.35.72] | 發表日期 : 2017-08-12 15:11

try:
s=input()
if (s.split(' ')[0]=='Meep'):
print('28')
else:
print('1')

except UnicodeDecodeError:
import random
print (random.randrange(17, 28, 10))

 
#12562: Re:Python (運氣好就會過(?))


icube (!@#$%^&*()_+)

學校 : 國立臺灣師範大學附屬高級中學
編號 : 61090
來源 : [220.135.116.184]
最後登入時間 :
2024-04-01 14:01:32
d430. 第二題: 計算字數 (count) -- 92學年度北基區資訊學科能力競賽 | From: [220.135.116.184] | 發表日期 : 2017-08-12 17:17

 
import codecs
import re
import sys
sys.stdin = codecs.getreader('latin-1')(sys.stdin.detach())
print(sum([len(re.sub('[^A-Za-z0-9 ]', '', line).split()) for line in sys.stdin]))

用奇怪的方式寫過了...

 
#16368: Re:Python (運氣好就會過(?))


inthewing (Hsu)

學校 : 國立中正大學
編號 : 29488
來源 : [39.15.2.129]
最後登入時間 :
2023-04-02 00:15:55
d430. 第二題: 計算字數 (count) -- 92學年度北基區資訊學科能力競賽 | From: [180.217.242.212] | 發表日期 : 2018-12-25 00:06

 
import codecs
import re
import sys
sys.stdin = codecs.getreader('latin-1')(sys.stdin.detach())
print(sum([len(re.sub('[^A-Za-z0-9 ]', '', line).split()) for line in sys.stdin]))

用奇怪的方式寫過了...


Seems the encoding method of the test files is not common 'utf-8', I tried to read in binary mode and decode('windows-1252')  can also work.

 

 
ZeroJudge Forum