#1012 数字分类 (20 分)
代码展示:
data = list(map(int,input().split()))
# print(data)
N = data[0] # 获得待分类的所有正整数的数量
data = data[1:] # 获得所有待分类的所有正整数
list_A1 = []
list_A2 = []
list_A3 = []
list_A4 = []
list_A5 = []
for item in data:
if item%5 == 0 and item%2 == 0:
list_A1.append(item)
elif item%5 == 1:
list_A2.append(item)
elif item%5 == 2:
list_A3.append(item)
elif item%5 == 3:
list_A4.append(item)
elif item%5 == 4:
list_A5.append(item)
if len(list_A1)==0:
A1 = 'N'
else:
A1 = sum(list_A1)
if len(list_A2)==0:
A2 = 'N'
else:
A2 = sum(list_A2[0::2])-sum(list_A2[1::2])
if len(list_A3)==0:
A3 = 'N'
else:
A3 = len(list_A3)
if len(list_A4)==0:
A4 = 'N'
else:
# A4 = "{0:.1f}".format(sum(list_A4)/len(list_A4))
A4 = round(sum(list_A4)/len(list_A4),1)
if len(list_A5)==0:
A5 = 'N'
else:
A5 = max(list_A5)
print(A1, A2, A3, A4, A5)
测评结果: