結果
問題 | No.1731 Product of Subsequence |
ユーザー |
![]() |
提出日時 | 2021-11-07 03:02:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 843 ms / 2,000 ms |
コード長 | 450 bytes |
コンパイル時間 | 338 ms |
コンパイル使用メモリ | 82,300 KB |
実行使用メモリ | 82,048 KB |
最終ジャッジ日時 | 2024-11-08 05:05:51 |
合計ジャッジ時間 | 10,482 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
n, k = map(int, input().split()) A = list(map(int, input().split())) mod = 10**9+7 from collections import defaultdict import math dp = defaultdict(lambda: 0) dp[1] = 1 for a in A: a = math.gcd(a, k) nx = defaultdict(lambda: 0) for j, v in dp.items(): nx[j] += v nx[j] %= mod g = math.gcd(j*a, k) nx[g] += v nx[g] %= mod dp = nx if k == 1: print((dp[k]-1)%mod) else: print(dp[k]%mod)