結果
問題 | No.2394 部分和乗総和 |
ユーザー | lloyz |
提出日時 | 2023-07-30 01:41:11 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 448 bytes |
コンパイル時間 | 137 ms |
コンパイル使用メモリ | 82,568 KB |
実行使用メモリ | 567,404 KB |
最終ジャッジ日時 | 2024-04-17 03:53:53 |
合計ジャッジ時間 | 4,795 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
55,092 KB |
testcase_01 | AC | 33 ms
54,660 KB |
testcase_02 | AC | 35 ms
54,308 KB |
testcase_03 | AC | 33 ms
54,852 KB |
testcase_04 | AC | 33 ms
54,132 KB |
testcase_05 | AC | 36 ms
55,048 KB |
testcase_06 | AC | 35 ms
53,716 KB |
testcase_07 | AC | 37 ms
55,444 KB |
testcase_08 | AC | 52 ms
65,716 KB |
testcase_09 | AC | 43 ms
61,976 KB |
testcase_10 | AC | 39 ms
54,116 KB |
testcase_11 | AC | 41 ms
61,848 KB |
testcase_12 | AC | 35 ms
54,336 KB |
testcase_13 | MLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
ソースコード
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)