#题解1 # # import sys # #计算名字分数 # #创建一个字典,统计字符的个数,然后按照个数排序.个数越多,用越多的漂亮度 # def get_score(name): # dic = {} # for c in name: # if c in dic: # dic[c] += 1 # else: # dic[c] = 1 # t_list = list(dic.values()) # t_list.sort(reverse = True) # #只需要知道重复字符的个数,排序.重复个数越多的,用越多的漂亮度 # score = 0 # for i in range(len(t_list)): # score += (26 - i) * t_list[i] # return score # while True: # try: # num = int(input()) # for i in range(num): # print(get_score(input())) # except: # # print(sys.exc_info()) # break #题解2 # import sys #计算名字分数 #使用集合收集名字里不重复的字符,再使用字符串函数count统计字符个数,个数越多的,用越多的漂亮度 def get_score(name): s = set(name) t_list = [] for c in s: t_list.append(name.count(c)) t_list.sort(reverse = True) score = 0 for i in range(len(t_list)): score += (26 - i) * t_list[i] return score while True: try: num = int(input()) for i in range(num): print(get_score(input())) except: # print(sys.exc_info()) break