题解 | #[NOIP2008]ISBN号码#
[NOIP2008]ISBN号码
http://www.nowcoder.com/practice/95712f695f27434b9703394c98b78ee5
a,b,c,d=input().split("-")
e=a+b+c
# print(e)
# print(d)
# print(len(e))
q=[x for x in range(1,10)]
s=0
for i in range(len(e)):
s=s+int(e[i])*q[i]
r=s%11
if d=="X" and r==10:
print("Right")
elif d=="X" and r!=10:
print(a+"-"+b+"-"+c+"-"+str(r))
elif d!="X" and r==10:
print(a+"-"+b+"-"+c+"-"+"X")
elif r==int(d):
print("Right")
else:
print(a+"-"+b+"-"+c+"-"+str(r))
- 大佬们的方法太妙了 值得反复看
python学习笔记 文章被收录于专栏
自学笔记记录