結果

問題 No.1731 Product of Subsequence
ユーザー Hydru
提出日時 2021-11-06 15:06:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 394 ms / 2,000 ms
コード長 431 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-11-08 04:59:51
合計ジャッジ時間 6,335 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from collections import defaultdict
mod=10**9+7
n,k=map(int,input().split())
if k==1:
    print(pow(2,n,mod)-1)
    exit()
A=list(map(lambda x:gcd(int(x),k),input().split()))
d=defaultdict(int)
d[1]=1
cnt=0
B=[]
for x in A:
    if x==1:
        cnt+=1
    else:
        B.append(x)

for i in B:
    d2=d.copy()
    for j in d2:
        m=gcd(k,i*j)
        d[m]=(d2[j]+d[m])%mod

print(d[k]*pow(2,cnt,mod)%mod)
0