結果

問題 No.1731 Product of Subsequence
ユーザー とりゐとりゐ
提出日時 2021-07-29 03:10:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 995 ms / 2,000 ms
コード長 294 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 79,360 KB
最終ジャッジ日時 2024-11-08 04:21:28
合計ジャッジ時間 11,232 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
if k==1:
  print(pow(2,n,mod)-1)
  exit()
import math
from collections import defaultdict
d=defaultdict(int)
d[1]=1
for i in a:
  d2=d.copy()
  for j in d2:
    m=math.gcd(k,i*j)
    d[m]=(d2[j]+d[m])%mod
print(d[k]%mod)
0