結果

問題 No.1731 Product of Subsequence
ユーザー H20
提出日時 2021-12-08 10:38:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 458 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 81,976 KB
実行使用メモリ 80,380 KB
最終ジャッジ日時 2024-07-16 02:57:00
合計ジャッジ時間 9,402 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))
mod = 10**9+7
for i in range(N):
    A[i] = math.gcd(A[i],K)

DP = collections.defaultdict(int)
DP[1]=1
for a in A:
    NDP = collections.defaultdict(int)
    CDP = DP.copy()

    for k,v in CDP.items():
        gcd = math.gcd(K,a*k)
        NDP[gcd]=(NDP[gcd]+DP[k])%mod
    for k,v in CDP.items():
        NDP[k]=(NDP[k]+DP[k])%mod
    DP = NDP
print(DP[K])
0