結果

問題 No.2394 部分和乗総和
ユーザー lloyz
提出日時 2023-07-30 01:41:11
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 448 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 524,036 KB
最終ジャッジ日時 2024-10-08 14:03:31
合計ジャッジ時間 6,050 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 MLE * 1 -- * 7
権限があれば一括ダウンロードができます

ソースコード

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 + a] += DP[j]
    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