代码展示:
N = eval(input())
numbers = list(map(eval,(input().split())))
def getFriendsNum(num):
num = str(num)
count = 0
for char in num:
count += int(char)
return count
dic = {}
for num in numbers:
Friendnum = getFriendsNum(num)
dic[Friendnum] = dic.get(Friendnum,0) + 1
lis = list(dic.items())
# print(lis)
# lis = [item for item in lis if item[1]>1]
# print(lis)
lis = [item[0] for item in lis]
# print(lis)
lis.sort()
# print(lis)
print(len(lis))
lis = list(map(str,lis))
print(" ".join(lis))
测评结果: