py3求解

P1055 [NOIP2008 普及组] ISBN 号码

Gaojiangbo @ 2022-07-19 10:44:28

第四个测试点一直过不去,自己测试的结果是对的

s=input()
s1=s[0:12]
s2=s1.replace('-','')
n=1
su=0
for i in s2:
    i=int(i)
    su+=i*n
    n+=1
a=s[-1]
if a.isdigit()==True:
    a=int(a)
if su%11==a :
    print('Right')
elif (a=='X' and su%11==10):
    print('Right')
else:
    if su%11<10:
        print(s1+str(su%11))
    elif su%11==10:
        print(s1+'X')

by Joker_1212 @ 2022-07-19 10:58:50

@Gaojiangbo 把

s = input()

换成

s = input().strip()

by Gaojiangbo @ 2022-07-19 11:34:27

@Joker_1212 过了过了,谢谢大佬


by Lonerwcq @ 2022-10-06 17:09:10

@Joker_1212 我去,加个strip我就全过了


|