QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#692433#5460. Sum of NumbersEsoulingWA 49ms11952kbPython3900b2024-10-31 14:29:572024-10-31 14:30:47

Judging History

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

  • [2024-10-31 14:30:47]
  • 评测
  • 测评结果:WA
  • 用时:49ms
  • 内存:11952kb
  • [2024-10-31 14:29:57]
  • 提交

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'