题解 | #名字的漂亮度#

名字的漂亮度

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

#究极简便字典用法
n = int(input())
while 1:
    try:
        lst = list(input())
        dic = {}
        for x in lst:
            if x in dic.keys():
                dic[x] += 1
            else:
                dic[x] = 1

         dic = dict(sorted(dic.items(), key = lambda x:x[1], reverse=True))

        ret = 0
        num = 26
        for i in dic.keys():
            ret += dic[i] * num
            num -= 1
        print(ret)
    except:
        break


全部评论

相关推荐

xtu大迫杰:偶遇校友,祝校友offer打牌
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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