QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#524860#5460. Sum of Numberssolar_express#Compile Error//C++14413b2024-08-20 09:49:382024-08-20 09:49:38

Judging History

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

  • [2024-08-20 09:49:38]
  • 评测
  • [2024-08-20 09:49:38]
  • 提交

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)

詳細信息

answer.code:1:1: error: ‘from’ does not name a type
    1 | from itertools import permutations
      | ^~~~