結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 506 ms
77,672 KB
testcase_01 AC 42 ms
54,068 KB
testcase_02 AC 42 ms
54,068 KB
testcase_03 AC 42 ms
54,824 KB
testcase_04 AC 43 ms
55,640 KB
testcase_05 AC 51 ms
61,816 KB
testcase_06 AC 49 ms
62,388 KB
testcase_07 AC 43 ms
55,708 KB
testcase_08 AC 65 ms
67,388 KB
testcase_09 AC 41 ms
59,588 KB
testcase_10 AC 542 ms
77,016 KB
testcase_11 AC 464 ms
77,212 KB
testcase_12 AC 61 ms
67,880 KB
testcase_13 AC 64 ms
69,144 KB
testcase_14 AC 387 ms
77,024 KB
testcase_15 AC 41 ms
55,032 KB
testcase_16 AC 39 ms
52,396 KB
testcase_17 AC 43 ms
55,208 KB
testcase_18 AC 351 ms
76,840 KB
testcase_19 AC 66 ms
69,536 KB
testcase_20 AC 284 ms
77,020 KB
testcase_21 AC 495 ms
76,884 KB
testcase_22 AC 63 ms
69,444 KB
testcase_23 AC 39 ms
59,556 KB
testcase_24 AC 64 ms
69,228 KB
testcase_25 AC 62 ms
69,564 KB
testcase_26 AC 130 ms
76,876 KB
testcase_27 AC 160 ms
76,900 KB
testcase_28 AC 270 ms
76,632 KB
testcase_29 AC 141 ms
76,640 KB
testcase_30 AC 493 ms
77,440 KB
testcase_31 AC 62 ms
68,972 KB
testcase_32 AC 40 ms
58,360 KB
testcase_33 AC 68 ms
68,900 KB
testcase_34 AC 83 ms
75,652 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()
  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