QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524874#5460. Sum of Numberssolar_express#RE 0ms0kbPython3475b2024-08-20 09:55:312024-08-20 09:55:33

Judging History

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

  • [2024-08-20 09:55:33]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-08-20 09:55:31]
  • 提交

answer

from itertools import permutations
import sys
import gmpy2
sys.set_int_max_str_digits(200002)
T = int(input())
for _ in range(T):
    n, k = map(int, input().split())
    s = input()
    ans = int(s)
    k = min(k, n-1)+1
    u = n//k
    r = n % k
    grp = [u]*(k-r)+[u+1]*r
    for lst in permutations(grp):
        i = 0
        cur = 0
        for x in lst:
            cur += int(s[i:i+x])
            i+=x
        ans = min(ans, cur)
    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:


result: