結果

問題 No.1731 Product of Subsequence
ユーザー とりゐとりゐ
提出日時 2021-10-18 03:47:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 537 ms / 2,000 ms
コード長 332 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 82,340 KB
実行使用メモリ 77,300 KB
最終ジャッジ日時 2024-04-25 17:10:05
合計ジャッジ時間 7,316 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 499 ms
77,300 KB
testcase_01 AC 42 ms
54,716 KB
testcase_02 AC 42 ms
55,376 KB
testcase_03 AC 41 ms
54,476 KB
testcase_04 AC 41 ms
54,644 KB
testcase_05 AC 47 ms
61,836 KB
testcase_06 AC 48 ms
62,600 KB
testcase_07 AC 43 ms
54,804 KB
testcase_08 AC 66 ms
67,420 KB
testcase_09 AC 40 ms
59,336 KB
testcase_10 AC 537 ms
77,144 KB
testcase_11 AC 487 ms
76,892 KB
testcase_12 AC 61 ms
68,560 KB
testcase_13 AC 64 ms
69,308 KB
testcase_14 AC 389 ms
77,236 KB
testcase_15 AC 42 ms
55,696 KB
testcase_16 AC 39 ms
52,684 KB
testcase_17 AC 43 ms
53,980 KB
testcase_18 AC 359 ms
76,952 KB
testcase_19 AC 65 ms
69,348 KB
testcase_20 AC 290 ms
76,944 KB
testcase_21 AC 500 ms
76,884 KB
testcase_22 AC 62 ms
68,856 KB
testcase_23 AC 40 ms
58,828 KB
testcase_24 AC 63 ms
68,552 KB
testcase_25 AC 59 ms
67,080 KB
testcase_26 AC 130 ms
76,944 KB
testcase_27 AC 163 ms
76,868 KB
testcase_28 AC 273 ms
76,892 KB
testcase_29 AC 141 ms
76,880 KB
testcase_30 AC 497 ms
77,068 KB
testcase_31 AC 60 ms
68,624 KB
testcase_32 AC 40 ms
59,684 KB
testcase_33 AC 63 ms
68,676 KB
testcase_34 AC 83 ms
75,100 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
d=defaultdict(int)
d[1]=1
for i in a:
  d2=d.copy()
  i=math.gcd(k,i)
  for j in d2:
    m=math.gcd(k,i*j)
    d[m]+=d2[j]
    if d[m]>=mod:
      d[m]-=mod
print(d[k])
0