python 60分求助

P1055 [NOIP2008 普及组] ISBN 号码

DragonRock37 @ 2024-10-29 08:16:03

a = input().strip()
a = ''.join(i for i in a if i != '-')
b = a[len(a)-1]
a = a[:len(a)-1]
s = 0
for i in range(len(a)):
    s += int(a[i]) * (i+1)
c = s % 11
if c == 10:
    c = 'X'
if int(b) == c:
    print('Right')
else:
    print(a[:1]+'-'+a[1:4]+'-'+a[4:]+'-'+str(c))

|