题解 | #名字的漂亮度#
名字的漂亮度
http://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3
def beauty_strings(n,strings): dic = {} sum_1 = 0 c = [] a = len(set(strings)) for i in strings: dic[i] = dic.get(i,0) + 1 for i,j in sorted(dic.items(),key=lambda x:-x[1]): c.append(j) for i,j in zip(range(26,26-a,-1),c): sum_1 += i*j print(sum_1) n = int(input().strip()) for i in range(n): strings = input().strip() beauty_strings(n,strings)