题解 | #名字的漂亮度#

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

while True:
    try:
        n = int(input())
        arr0, i = [], 0
        while i < n:
            j = input()
            if 1 <= len(j) <= 10000 and j.islower():
                arr0.append(j)
                i += 1
            else:
                continue
        for str1 in arr0:
            num = [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
            str0 = ''.join(list(set(list(str1))))
            dic0 = {}
            for x in str0:
                k = str1.count(x)
                if k in dic0.keys():
                    dic0[k] = dic0[k] + x
                else:
                    dic0[k] = x
            arr1 = []
            for k in dic0.keys():
                arr1.append(k)
            arr1.sort(reverse=True)
            ss =  0
            for key in range(len(arr1)):
                ll = list(dic0[arr1[key]])
                for a in range(len(ll)):
                    ss += num[0] * arr1[key]
                    num.pop(0)
            print(ss)
        break
    except:
        break


全部评论

相关推荐

Gardenia06...:刚开始学是这样的,可以看看左神和灵神都讲的不错
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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