結果
| 問題 | No.1731 Product of Subsequence | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-10-20 16:49:07 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 395 bytes | 
| コンパイル時間 | 299 ms | 
| コンパイル使用メモリ | 82,828 KB | 
| 実行使用メモリ | 345,828 KB | 
| 最終ジャッジ日時 | 2024-06-30 09:09:47 | 
| 合計ジャッジ時間 | 6,627 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | -- * 4 | 
| other | TLE * 1 -- * 30 | 
ソースコード
from collections import defaultdict MOD = 10 ** 9 + 7 n, k = map(int, input().split()) a = list(map(int, input().split())) if k == 1: print((pow(2, n, MOD) - 1) % MOD) exit() dp = defaultdict(int) dp[1] = 1 for i in range(n): ndp = defaultdict(int) for x, v in dp.items(): ndp[x] = (ndp[x] + v) % MOD nx = (x * a[i]) % k ndp[nx] = (ndp[nx] + v) % MOD dp = ndp print(dp[0])
