题解 | 名字的漂亮度
def bea_word(w): w_dict = {} for char in w: if char in w_dict: w_dict[char] += 1 elif char not in w_dict: w_dict[char] = 1 sorted_w_dict = sorted(w_dict.items(), key=lambda x: x[1], reverse=True) length = 0 for i in range(len(sorted_w_dict)): length += int(sorted_w_dict[i][1])*(26-i) return length n = int(input()) for i in range(n): print(bea_word(input()))