201312-2CCF认证考试 IBSN数 Python版

第一题出现次数最多的数

201312-2CCF认证考试 IBSN数 Python版_第1张图片

满分答案:

num = list(map(int,input().split('-')))
a = str(num[0]) + str(num[1]) + str(num[2])
a_1 = [i for i in a]
s = 0
for i in range(9):
    s = s + (int(a_1[i]) * (i+1))
b = int(s % 11)
if b == 10:
    if b == num[3]:
        print("Right")
    else:
        print(num[0],end='')
        print("-",end='')
        print(num[1],end='')
        print("-",end='')
        print(num[2],end='')
        print("-",end='')
        print('X')
else:
    if b == num[3]:
        print("Right")
    else:
        print(num[0],end='')
        print("-",end='')
        print(num[1],end='')
        print("-",end='')
        print(num[2],end='')
        print("-",end='')
        print(b)

 

你可能感兴趣的:(CCF-Python,python,算法,列表)