結果

問題 No.2394 部分和乗総和
ユーザー lloyzlloyz
提出日時 2023-07-30 01:43:18
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 492 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 540,504 KB
最終ジャッジ日時 2024-04-17 03:55:54
合計ジャッジ時間 4,423 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
59,136 KB
testcase_01 AC 34 ms
53,856 KB
testcase_02 AC 35 ms
53,760 KB
testcase_03 AC 36 ms
54,016 KB
testcase_04 AC 35 ms
54,016 KB
testcase_05 AC 35 ms
53,632 KB
testcase_06 AC 34 ms
53,376 KB
testcase_07 AC 35 ms
53,888 KB
testcase_08 AC 50 ms
67,072 KB
testcase_09 AC 45 ms
62,476 KB
testcase_10 AC 36 ms
54,400 KB
testcase_11 AC 44 ms
62,464 KB
testcase_12 AC 35 ms
53,248 KB
testcase_13 MLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import sys
input = sys.stdin.readline

n, m, b = map(int, input().split())
A = list(map(int, input().split()))

DP = defaultdict(int)
DP[0] = 1
for i in range(n):
    a = A[i]
    N = sorted(DP.keys())
    NDP = defaultdict(int)
    for j in N:
        NDP[j] += DP[j]
        NDP[j] %= b
        NDP[j + a] += DP[j]
        NDP[j + a] %= b
    DP = NDP
ans = 0
N = sorted(DP.keys())
for i in N:
    ans += DP[i] * pow(m, i, b) % b
    ans %= b
print(ans)
0