結果
問題 | No.1731 Product of Subsequence |
ユーザー |
|
提出日時 | 2022-03-16 17:37:34 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 470 bytes |
コンパイル時間 | 156 ms |
コンパイル使用メモリ | 82,172 KB |
実行使用メモリ | 87,680 KB |
最終ジャッジ日時 | 2024-09-24 17:56:31 |
合計ジャッジ時間 | 10,103 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 WA * 4 |
ソースコード
N,K = map(int,input().split()) A = list(map(int,input().split())) def gcd(a,b): while True: r = a % b a = b b = r if r == 0:return a A = [gcd(a,K) for a in A] P = 10 ** 9 + 7 from collections import defaultdict dp = defaultdict(int) dp[1] = 1 for a in A: nx = defaultdict(int) for i in dp: nx[gcd(i * a,K)] += dp[i] for k in dp: nx[k] += dp[k] for k in nx: nx[k] %= P dp = nx print(dp[K])