tang_123458 @ 2024-03-27 19:29:31
这个题不是看得太懂,用Python写的代码,不知道哪里出问题了。输入样例:You are a three eight pig .,我得到的结果是1964,而标准答案是10964.不知道为甚么是10.1的平方不是1吗?
#斯诺登密码
s1 = "one two three four five six seven eight nine ten eleven twelve"
s2 = " thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty"
s3 = " a both another first second third"
s =s1 + s2 + s3
lst = s.split()
nums = [i for i in range(1,21)]
n = [1,2,1,1,2,3]
nums.extend(n)
#print(nums)
dct = {}
for key,val in zip(lst,nums):
dct[key] = val
#print(dct.keys())
mima = []
str1 = input().split()
for word in str1:
if word in dct.keys():
a = dct[word] ** 2 % 100
if a != 0:
mima.append(a)
if len(mima):
mima.sort()
mima = [str(i) for i in mima]
print(''.join(mima))
else:
print(0)
by tang_123458 @ 2024-03-28 08:44:45
过了,认真读题,认真读题
#斯诺登密码
s1 = "one two three four five six seven eight nine ten eleven twelve"
s2 = " thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty"
s3 = " a both another first second third"
s =s1 + s2 + s3
lst = s.split()
nums = [i for i in range(1,21)]
n = [1,2,1,1,2,3]
nums.extend(n)
#print(nums)
dct = {}
for key,val in zip(lst,nums):
dct[key] = val
#print(dct.keys())
mima = []
str1 = input().split()
for word in str1:
if word in dct.keys():
a = dct[word] ** 2 % 100
if a != 0:
mima.append(a)
if len(mima):
mima.sort()
for i in range(len(mima)):
if i != 0 and mima[i] < 10:
mima[i] = '0'+str(mima[i])
else:
mima[i] = str(mima[i])
print(''.join(mima))
else:
print(0)