其他分享
首页 > 其他分享> > 牛客华为机试HJ92

牛客华为机试HJ92

作者:互联网

原题传送门

1. 问题描述

2. Solution

import sys
from collections import defaultdict

if sys.platform != "linux":
    sys.stdin = open("input/HJ92.txt")


def solve(s):
    import re
    parts = re.split(r'\D+', s)
    res = defaultdict(list)
    for part in parts:
        if len(part) == 0:
            continue
        res[len(part)].append(part)
    n, nums = sorted(res.items(), key=lambda x: x[0])[-1]
    print(f'''{"".join(nums)},{n}''')


for line in sys.stdin:
    s = line.strip()
    solve(s)

标签:re,res,parts,sys,牛客,part,import,机试,HJ92
来源: https://www.cnblogs.com/junstat/p/16177315.html