QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#524874 | #5460. Sum of Numbers | solar_express# | RE | 0ms | 0kb | Python3 | 475b | 2024-08-20 09:55:31 | 2024-08-20 09:55:33 |
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