QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#355852#5460. Sum of Numbersucup-team1001#RE 0ms0kbPython3972b2024-03-17 11:26:462024-03-17 11:26:47

Judging History

你现在查看的是最新测评结果

  • [2024-03-17 11:26:47]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-03-17 11:26:46]
  • 提交

answer

a = 0
b = 0
qwq = ""
ans = 0
vis = 0
now = []
n = 0
k = 0


def check():
    now2 = []
    global a, b, n, k, ans, vis, now
    a = (n // (k + 1))
    b = ((n + k) // (k + 1))
    cur = 0
    if sum(now) != n - (n // (k + 1) * (k + 1)):
        return
    for x in now:
        if x == 0:
            now2.append(int(qwq[cur: cur + a]))
            cur += a
        else:
            now2.append(int(qwq[cur: cur + b]))
            cur += b
    if vis == 0:
        ans = sum(now2)
    else:
        ans = max(ans, sum(now2))


def dfs(cur):
    global a, b, n, k, ans, vis, now
    x = n // (k + 1)
    if cur == k + 1:
        check()
        return
    else:
        now.append(0)
        dfs(cur + 1)
        now.pop(cur)
        now.append(1)
        dfs(cur + 1)
        now.pop(cur)


t = int(input())
while t:
    ans = 0
    n, k = [int(x) for x in input().split()]
    qwq = input()
    dfs(0)
    print(ans)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

2
8 1
45455151
2 1
42

output:

9696
6

result: