結果
問題 | No.137 貯金箱の焦り |
ユーザー | 👑 rin204 |
提出日時 | 2022-10-02 15:29:37 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 744 bytes |
コンパイル時間 | 296 ms |
コンパイル使用メモリ | 86,880 KB |
実行使用メモリ | 83,976 KB |
最終ジャッジ日時 | 2023-08-26 11:10:07 |
合計ジャッジ時間 | 10,826 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 97 ms
76,240 KB |
testcase_01 | AC | 84 ms
76,196 KB |
testcase_02 | AC | 97 ms
76,220 KB |
testcase_03 | AC | 73 ms
71,304 KB |
testcase_04 | AC | 946 ms
76,864 KB |
testcase_05 | AC | 164 ms
76,580 KB |
testcase_06 | AC | 337 ms
76,572 KB |
testcase_07 | AC | 195 ms
76,492 KB |
testcase_08 | AC | 232 ms
76,232 KB |
testcase_09 | AC | 416 ms
76,568 KB |
testcase_10 | AC | 231 ms
76,452 KB |
testcase_11 | AC | 80 ms
75,724 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
MOD = 1234567891 def multiply(A, B): n = len(A) m = len(B) C = [0] * (n + m - 1) for i, a in enumerate(A): for j, b in enumerate(B): C[i + j] += a * b C[i + j] %= MOD return C # [x ^ n] P(x) / Q(x) def BostanMori(P, Q, n): while n: R = [(x * (-1) ** (i % 2)) % MOD for i, x in enumerate(Q)] Q = multiply(Q, R)[::2] P = multiply(P, R)[n % 2::2] n >>= 1 return P[0] * pow(Q[0], MOD - 2, MOD) % MOD n, m = map(int, input().split()) A = list(map(int, input().split())) tot = sum(A) dp = [0] * (tot + 1) dp[0] = 1 for a in A: for i in range(tot, a - 1, -1): dp[i] -= dp[i - a] dp[i] %= MOD ans = BostanMori([1], dp, m) print(ans)