CCF CSP 201312-1/2 出现次数最多的数/ISBN号码 python

201312-1 出现次数最多的数

CCF CSP 201312-1/2 出现次数最多的数/ISBN号码 python_第1张图片

n = int(input())
data = list(map(int,input().split()))
result = {
     }
for i in range(n):
    if data[i] not in result:
        result[data[i]] = data.count(data[i])

result_sort = sorted(result.items(),key=lambda x:(-x[1],x[0]))
print(result_sort[0][0])

201312-2 ISBN号码
CCF CSP 201312-1/2 出现次数最多的数/ISBN号码 python_第2张图片
一定要记得边界问题!余数为10的情况,不然扣20分

data = list(input())
number = ['0','1','2','3','4','5','6','7','8','9']
mul = 1
sum_=0
for i in range(len(data)-1):
    if data[i] in number:
        sum_ += int(data[i])*mul
        mul+=1

result = sum_ % 11

if str(result) == data[-1] or (result == 10 and data[-1] == 'X'):
    print("Right")
else:
    if str(result) == '10':
        data[-1]="X"
    else:
        data[-1]= str(result)

    for i in data:
        print(i,end="")

你可能感兴趣的:(CCF,CSP,python)