深信服。9、1

第一:日志
T = int(input())
store = []
for _ in range(T):
    store.append(input())
mode = 10**9+7
for item in store:
    s_count = 0
    w_socre = 0
    ans = 0
    for ch in item:
        if ch == "s":
            s_count += 1
        elif ch == "w":
            temp = w_socre + s_count
            w_socre = temp
        elif ch == "r":
            ans += w_socre
    print(ans % mode)
第二:旅游
T = int(input())
store = []
for _ in range(T):
    N = int(input())
    mid = []
    for _ in range(N):
        s, e = map(int, input().split())
        mid.append([s, e])
    store.append([N,mid])
for item in store:
    N = item[0]
    mid = item[1]
    time = []
    for s, e in mid:
        time.append((s,"a"))
        time.append((e,"b"))
    time.sort(key = lambda x: [x[0],x[1]])
    ans = 0
    cur = 0
    for t, c in time:
        if c == "a":
            cur += 1
        elif c == "b":
            cur -= 1
        ans = max(cur, ans)
    print(ans)
第三:五进制
T = int(input())
store = []
for _ in range(T):
    store.append(input())
mdic = {"o":0,"y":1,"e":2,"a":3,"s":4}
rdic = {"0":"o", "1":"y","2":"e","3":"a","4":"s"}
def change(n, x):
    a = [0, 1, 2, 3, 4]
    b = []
    while True:
        s = n // x
        y = n % x
        b = b + [y]
        if s == 0:
            break
        n = s
    result = [rdic[str(a[i])] for i in b[::-1]]
    return "".join(result)

for item in store:
    if item[0].isdigit():
        tar = change(int(item), 5)
        print(tar)
    else:
        ans = [str(mdic[t]) for t in item]
        print(int("".join(ans), 5))






全部评论

相关推荐

看网上风评也太差了
投递万得信息等公司8个岗位 >
点赞 评论 收藏
转发
头像
04-29 10:53
已编辑
东北大学 自动化类
点赞 评论 收藏
转发
点赞 2 评论
分享
牛客网
牛客企业服务