QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#524861#5460. Sum of Numberssolar_express#RE 5ms10552kbPython3413b2024-08-20 09:49:482024-08-20 09:49:48

Judging History

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

  • [2024-08-20 09:49:48]
  • 评测
  • 测评结果:RE
  • 用时:5ms
  • 内存:10552kb
  • [2024-08-20 09:49:48]
  • 提交

answer

from itertools import permutations
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)

詳細信息

Test #1:

score: 100
Accepted
time: 5ms
memory: 10552kb

input:

2
8 1
45455151
2 1
42

output:

9696
6

result:

ok 2 lines

Test #2:

score: -100
Dangerous Syscalls

input:

10
1301 6
56328399613959594774559774218276494124991536454496431869449134772679831477279356599352619469813771742358572734317965823527349354276551857226632977613336815474383422853946661428822284645652423563864641261338984158269966469425994769486371736593879954275146732544891889693921182364554588732946...

output:

2861837555106640794797067737879913860686764066159587941287350938727749577629356630565034353414526438507603808735990935008225192080065174423508575377930722196909797866802717925250679901255

result: