QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#692433 | #5460. Sum of Numbers | Esouling | WA | 49ms | 11952kb | Python3 | 900b | 2024-10-31 14:29:57 | 2024-10-31 14:30:47 |
Judging History
answer
import sys
sys.set_int_max_str_digits(100000)
t = int(input())
inf = int(int(1e5) * '1')
for tt in range(t):
n, k = map(int, input().split())
s = input()
len = n // (k + 1)
r = n - len * (k + 1)
ans = 0
cur = 0
if n % (k + 1) == 0:
len = n // (k + 1)
while cur < n:
ans += int(s[cur : cur + len])
# print(cur, cur + len, s[cur : cur + len])
cur += len
print(ans)
continue
ans = inf
# print(len, r)
for j in range(k + 1):
cnt = 0
temp = 0
cur = 0
while cur < n:
if cnt == j:
temp += int(s[cur : cur + r])
cur += r
else:
temp += int(s[cur : cur + len])
cur += len
cnt += 1
ans = min(ans, temp)
print(ans)
详细
Test #1:
score: 100
Accepted
time: 16ms
memory: 11880kb
input:
2 8 1 45455151 2 1 42
output:
9696 6
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 49ms
memory: 11952kb
input:
10 1301 6 56328399613959594774559774218276494124991536454496431869449134772679831477279356599352619469813771742358572734317965823527349354276551857226632977613336815474383422853946661428822284645652423563864641261338984158269966469425994769486371736593879954275146732544891889693921182364554588732946...
output:
275322559147104034949648709733658426902712691965482877647094746483878814496443382257041536870824467389126159675046510266740773176861508454468294595967437685802780984671773970894576447403 40393473728982689670444657631029010031191819105599198940813192420676640883353514915260802151374379798840866673314...
result:
wrong answer 1st lines differ - expected: '286183755510664079479706773787...6909797866802717925250679901255', found: '275322559147104034949648709733...5802780984671773970894576447403'