题解 | #名字的漂亮度#
名字的漂亮度
https://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3
#获取输入的字符串 n = int(input()) for i in range(n): name = input() #用字典存储字母和总个数 dic = {} for word in name: if word not in dic: dic[word] = 1 else: dic[word]+=1 dic1 = sorted(dic.values(),reverse=True) #根据value进行排序 res = 0 m = 0 #用来记录排序的个数 for word in dic1: res = res +(26-m)*word #如果该字母有多个,则word是字母的个数 m +=1 print(res)