QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#676484#8790. First BillionmalkovskyWA 15ms10740kbPython31.3kb2024-10-25 21:46:472024-10-25 21:46:49

Judging History

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

  • [2024-10-25 21:46:49]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:10740kb
  • [2024-10-25 21:46:47]
  • 提交

answer


def knapsap_mod(nums, mod):
    numbers = [num % mod for num in nums]
    dp = [[0 for i in range(mod)] for _ in range(len(numbers) + 1)]
    dp[0][0] = 1

    for i in range(len(numbers)):
        for j in range(mod):
            if dp[i][j] == 1:
                dp[i + 1][(j + numbers[i]) % mod] = 1
                dp[i + 1][(j + mod - numbers[i]) % mod] = 1

    # print(dp[len(numbers)][0])

    if dp[len(numbers)][0] == 1:
        result = []
        n = len(numbers)
        cur = 0
        while n > 0:
            left = (cur + (mod - numbers[n - 1])) % mod
            right = (cur + numbers[n - 1]) % mod
            if dp[n - 1][left] == 1:
                cur = left
            else:
                cur = right
                result.append(n - 1)
            n -= 1

        return result





def __main__():
    n = int(input())
    numbers = list(map(int, input().split()))

    answer = []
    for mod in range(1001, 2001):
        result = knapsap_mod(numbers, mod)
        # print(result, sum([numbers[i] for i in result]) % mod)
        if sum([numbers[i] for i in result]) == 1000000000:
            answer = result
            break

        # print(num_at_least_k)

    for num in answer:
        print(num + 1, end=" ")


__main__()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 15ms
memory: 10740kb

input:

10
386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997

output:

9 7 6 5 1 

result:

wrong output format Unexpected end of file - int32 expected