結果

問題 No.1731 Product of Subsequence
ユーザー とりゐとりゐ
提出日時 2021-10-27 07:49:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 743 ms / 2,000 ms
コード長 324 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 77,424 KB
最終ジャッジ日時 2024-04-25 17:10:46
合計ジャッジ時間 9,139 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 619 ms
77,424 KB
testcase_01 AC 40 ms
54,764 KB
testcase_02 AC 40 ms
55,256 KB
testcase_03 AC 42 ms
54,780 KB
testcase_04 AC 42 ms
55,072 KB
testcase_05 AC 48 ms
62,208 KB
testcase_06 AC 49 ms
62,456 KB
testcase_07 AC 42 ms
54,132 KB
testcase_08 AC 70 ms
68,556 KB
testcase_09 AC 41 ms
58,548 KB
testcase_10 AC 743 ms
76,880 KB
testcase_11 AC 640 ms
77,180 KB
testcase_12 AC 59 ms
67,312 KB
testcase_13 AC 67 ms
68,836 KB
testcase_14 AC 558 ms
77,004 KB
testcase_15 AC 42 ms
54,724 KB
testcase_16 AC 37 ms
52,756 KB
testcase_17 AC 41 ms
55,140 KB
testcase_18 AC 467 ms
77,180 KB
testcase_19 AC 68 ms
68,396 KB
testcase_20 AC 381 ms
77,224 KB
testcase_21 AC 737 ms
77,196 KB
testcase_22 AC 60 ms
69,164 KB
testcase_23 AC 41 ms
58,540 KB
testcase_24 AC 71 ms
69,624 KB
testcase_25 AC 61 ms
66,956 KB
testcase_26 AC 172 ms
76,744 KB
testcase_27 AC 216 ms
76,752 KB
testcase_28 AC 377 ms
77,088 KB
testcase_29 AC 185 ms
77,364 KB
testcase_30 AC 608 ms
76,988 KB
testcase_31 AC 60 ms
68,804 KB
testcase_32 AC 41 ms
58,096 KB
testcase_33 AC 61 ms
68,956 KB
testcase_34 AC 101 ms
74,768 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=i%k+k
  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