QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#355858 | #5460. Sum of Numbers | ucup-team1001# | RE | 6ms | 9512kb | Python3 | 998b | 2024-03-17 11:48:32 | 2024-03-17 11:48:32 |
Judging History
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:
t -= 1
ans = 0
n, k = input().split()
n = int(n)
k = int(k)
qwq = input()
dfs(0)
print(ans)
詳細信息
Test #1:
score: 100
Accepted
time: 6ms
memory: 9512kb
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 2028602090143780469266128133078232131914493056881109246886996709763987748451038085499863940159856016004397963081...