結果
問題 |
No.2394 部分和乗総和
|
ユーザー |
|
提出日時 | 2023-07-30 01:43:18 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 492 bytes |
コンパイル時間 | 428 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 396,856 KB |
最終ジャッジ日時 | 2024-10-08 14:06:37 |
合計ジャッジ時間 | 4,868 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 TLE * 1 -- * 7 |
ソースコード
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)