题解 | #名字的漂亮度#

名字的漂亮度

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

while True:
    try:
        n = int(input())
        names = [input() for _ in range(n)]
        for name in names:
            dic = {}
            for c in name:
                if c not in dic:
                    dic[c] = 1
                else:
                    dic[c] += 1
            lst = list(sorted(dic.values(), reverse=True))
            total, point = 0, 26
            for i in lst:
                total += point * i
                point -= 1
            print(total)
    except:
        break
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务