import sys
a1=''
while True:
try:
line = sys.stdin.readline().strip()
if line == '':
break
else:
a1=a1+line
except:
break
#P1042 [NOIP2003 普及组] 乒乓球
完整代码
import sys
a1=''
while True:
try:
line = sys.stdin.readline().strip()
if line == '':
break
else:
a1=a1+line
except:
break
# print(a1)
b=0
c=0
for i in a1:
if (i == 'E'):
break
if(i=='W'):
b+=1
if(i=='L'):
c+=1
if(b>=11):
if (abs(b - c) >= 2):
print('%s:%s'%(b,c))
b=0
c=0
if (c >= 11):
if (abs(b - c) >= 2):
print('%s:%s' % (b, c))
c=0
b = 0
# print(i)
print('%s:%s' % (b, c))
print()
b=0
c=0
for i in a1:
if (i == 'E'):
break
if(i=='W'):
b+=1
if(i=='L'):
c+=1
if(b>=21):
if (abs(b - c) >= 2):
print('%s:%s'%(b,c))
b=0
c=0
if (c >= 21):
if (abs(b - c) >= 2):
print('%s:%s' % (b, c))
c=0
b = 0
print('%s:%s' % (b, c))
|