SingularityVVVIP @ 2022-09-10 21:34:08
l=input().split('-')
s=l[0]+l[1]+l[2]
n=0
d=0
for i in s:
n=n+1
d=d+int(i)*n
d=d%11
if d==10:
if l[3]=='X':
print('Right')
else:
print('{}-{}-{}-{}'.format(l[0],l[1],l[2],'X'))
else:
if l[3]==str(d):
print('Right')
else:
print('{}-{}-{}-{}'.format(l[0],l[1],l[2],d))
当输入为6-670-82162-X,输出'Right'。唯一一组WA。
by StenvenPig @ 2022-09-17 18:14:42
a = input()
b = a[:12]
c = 0
s = 1
lz = a[12]
for i in b:
if i!='-':
e = int(i)
c = c+e*s
s = s + 1
else:
continue
c = int(c)
c = c%11
if c==10:
q = 'X'
else:
q = str(c)
if q == lz:
print('Right')
else:
print(str(b)+str(q))
你这个代码有点让人疑惑啊,不用这么麻烦