题解 | #名字的漂亮度#

名字的漂亮度

http://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3

while True:
    try:
        m = int(input())
        for s in range(m):
            name = input()
            result = 0
            lists = list(set(name))
            list1 = sorted(lists, key=lambda x: name.count(x), reverse=True)
            time = 26
            for i in range(len(lists)):
                result += name.count(list1[i]) * time
                time -= 1
            print(result)
    except:
        break
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务