90分救助

P1055 [NOIP2008 普及组] ISBN 号码

X_7a @ 2022-07-13 20:28:36

第八个测试点过不去,自己试是对的,7-358-86245-2。。。7-358-86245-7

l=list(input())

for i in range(3):
    l.remove('-')

s=0
for i in range(1,9+1):
    s+=int(l[i-1])*i
x=s%11

if str(x) in (l[9]) or x==10 and l[9] in 'X':
    print('Right')

else:
    l.insert(1,'-')
    l.insert(5,'-')
    l.insert(11,'-')
    l.pop(len(l)-1)
    if x<10:
        l.append(str(x))
    else:
        l.append('X')
    p=''
    for i in range(len(l)):
        p+=str(l[i])
    print(p)

|