結果

問題 No.1731 Product of Subsequence
ユーザー とりゐとりゐ
提出日時 2021-10-14 07:41:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 443 ms / 2,000 ms
コード長 323 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 77,528 KB
最終ジャッジ日時 2024-04-25 17:08:06
合計ジャッジ時間 6,268 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 406 ms
77,212 KB
testcase_01 AC 41 ms
53,736 KB
testcase_02 AC 42 ms
55,056 KB
testcase_03 AC 42 ms
54,316 KB
testcase_04 AC 41 ms
54,752 KB
testcase_05 AC 47 ms
61,540 KB
testcase_06 AC 47 ms
62,028 KB
testcase_07 AC 42 ms
55,580 KB
testcase_08 AC 61 ms
67,088 KB
testcase_09 AC 41 ms
58,568 KB
testcase_10 AC 443 ms
76,972 KB
testcase_11 AC 377 ms
76,988 KB
testcase_12 AC 57 ms
67,100 KB
testcase_13 AC 59 ms
67,896 KB
testcase_14 AC 320 ms
76,864 KB
testcase_15 AC 43 ms
54,460 KB
testcase_16 AC 37 ms
52,968 KB
testcase_17 AC 42 ms
54,164 KB
testcase_18 AC 330 ms
77,184 KB
testcase_19 AC 61 ms
68,544 KB
testcase_20 AC 264 ms
76,976 KB
testcase_21 AC 408 ms
76,940 KB
testcase_22 AC 56 ms
66,796 KB
testcase_23 AC 41 ms
58,836 KB
testcase_24 AC 59 ms
68,124 KB
testcase_25 AC 56 ms
66,252 KB
testcase_26 AC 110 ms
76,732 KB
testcase_27 AC 134 ms
76,656 KB
testcase_28 AC 227 ms
76,708 KB
testcase_29 AC 116 ms
76,792 KB
testcase_30 AC 404 ms
77,528 KB
testcase_31 AC 56 ms
66,340 KB
testcase_32 AC 41 ms
58,156 KB
testcase_33 AC 57 ms
65,944 KB
testcase_34 AC 70 ms
72,424 KB
権限があれば一括ダウンロードができます

ソースコード

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
a=[math.gcd(i,k) for i in a]
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