题解 | #名字的漂亮度#
名字的漂亮度
https://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3
先排序字符的出现次数,在与【26-1】相乘
counts = list(range(26, 0, -1))
num = int(input())
j = 0
while j < num:
try:
dp = dict()
for i in input().upper():
if i not in dp:
dp[i] = 1
else:
dp[i] += 1
dp = sorted(dp.items(), key=lambda x: x[1], reverse=True)
# print(dp)
total = 0
for ide, val in enumerate(dp):
total += counts[ide] * val[1]
print(total)
j += 1
except:
break