Python2环境:
1021:
from sys import exit
str = raw_input()
digit = []
for i in str:
digit.append(i)
for i in range(10):
if digit.count('%d' % i) > 0:
print '%d:%d' % (i, digit.count('%d' % i))
exit(0)
1022:
from sys import exit
str = raw_input().split()
num = int(str[0]) + int(str[1])
d = int(str[2])
list = []
out = ''
if num == 0:
out = '0'
while num != 0:
list.append(num % d)
num /= d
list.reverse()
for i in list:
out += '%d' % i
print out
exit(0)
1023:
from sys import exit
str = raw_input().split()
num = [int(str[i]) for i in range(len(str))]
out = ''
flag = 0
for i in range(1, len(num)+1):
if num[i] != 0:
flag = i
break
out += '%d' % flag
for i in range(len(num)):
if i == flag:
out += ('%s' % i) * (num[i]-1)
else:
out += ('%s' % i) * num[i]
print out
exit(0)
1024:
from sys import exit
str = raw_input().split('E')
if str[1] != '':
index = int(str[1])
else:
index = 0
num = str[0]
intPart = num.split('.')[0]
xsPart = num.split('.')[1]
out = ''
if num[0] == '-':
out += '-'
if index == 0:
out = str[0]
elif index > 0:
out += '%d' % int(abs(int(intPart)))
if len(xsPart) <= index:
out += xsPart
out += '0' * (index - len(xsPart))
else:
out += xsPart[:index]
out += '.'
out += xsPart[index:]
else:
out += '0.'
out += '0' * (abs(index)-1)
out += '%d' % int(abs(int(intPart)))
out += xsPart
print out
exit(0)
1025:
#!/usr/bin/python
from sys import exit
str = raw_input().split()
dict = {}
ListLen = int(str[1])
revsLen = int(str[2])
list = []
for i in range(ListLen):
tmp = raw_input().split()
dict[tmp[0]] = tmp[1:]
cur = str[0]
for i in range(ListLen):
list.append([cur, dict[cur][0], dict[cur][1]])
cur = dict[cur][1]
count = 0
revList = []
while ListLen - count >= revsLen:
y=list[count:count+revsLen]
y.reverse()
count += revsLen
revList.extend(y)
revList.extend(list[count:])
cur = revList[0][0]
count = 0
while ListLen - count >= revsLen:
for i in range(revsLen-1):
revList[count+i][2] = revList[count+i+1][0]
if count + revsLen < ListLen:
revList[count+revsLen-1][2] = revList[count+revsLen][0]
count += revsLen
revList[-1][2] = '-1'
for i in range(ListLen):
print revList[i][0], revList[i][1], revList[i][2]
exit(0)
有一个case内存超限,还有一个没过,Python在时间效率和空间效率上还有待改进啊。。也没心情跳最后一个没过的case了。