結果

問題 No.1731 Product of Subsequence
ユーザー HydruHydru
提出日時 2021-11-06 15:06:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 351 ms / 2,000 ms
コード長 431 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 82,912 KB
実行使用メモリ 77,420 KB
最終ジャッジ日時 2024-04-25 17:41:15
合計ジャッジ時間 5,408 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 335 ms
77,200 KB
testcase_01 AC 38 ms
54,276 KB
testcase_02 AC 38 ms
54,432 KB
testcase_03 AC 37 ms
54,616 KB
testcase_04 AC 39 ms
54,712 KB
testcase_05 AC 43 ms
61,036 KB
testcase_06 AC 40 ms
55,588 KB
testcase_07 AC 40 ms
55,704 KB
testcase_08 AC 56 ms
65,900 KB
testcase_09 AC 38 ms
54,088 KB
testcase_10 AC 328 ms
77,420 KB
testcase_11 AC 286 ms
77,056 KB
testcase_12 AC 45 ms
61,740 KB
testcase_13 AC 55 ms
68,308 KB
testcase_14 AC 265 ms
77,128 KB
testcase_15 AC 38 ms
55,064 KB
testcase_16 AC 38 ms
54,468 KB
testcase_17 AC 38 ms
53,888 KB
testcase_18 AC 308 ms
77,076 KB
testcase_19 AC 56 ms
68,164 KB
testcase_20 AC 248 ms
77,092 KB
testcase_21 AC 327 ms
77,016 KB
testcase_22 AC 53 ms
68,016 KB
testcase_23 AC 39 ms
55,192 KB
testcase_24 AC 54 ms
68,740 KB
testcase_25 AC 53 ms
68,088 KB
testcase_26 AC 93 ms
76,788 KB
testcase_27 AC 111 ms
77,116 KB
testcase_28 AC 190 ms
77,000 KB
testcase_29 AC 100 ms
76,804 KB
testcase_30 AC 351 ms
77,140 KB
testcase_31 AC 55 ms
67,056 KB
testcase_32 AC 39 ms
54,392 KB
testcase_33 AC 52 ms
67,004 KB
testcase_34 AC 62 ms
70,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from collections import defaultdict
mod=10**9+7
n,k=map(int,input().split())
if k==1:
    print(pow(2,n,mod)-1)
    exit()
A=list(map(lambda x:gcd(int(x),k),input().split()))
d=defaultdict(int)
d[1]=1
cnt=0
B=[]
for x in A:
    if x==1:
        cnt+=1
    else:
        B.append(x)

for i in B:
    d2=d.copy()
    for j in d2:
        m=gcd(k,i*j)
        d[m]=(d2[j]+d[m])%mod

print(d[k]*pow(2,cnt,mod)%mod)
0