結果

問題 No.1731 Product of Subsequence
ユーザー HydruHydru
提出日時 2021-11-06 15:05:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 416 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-04-25 02:34:39
合計ジャッジ時間 6,459 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 44 ms
53,760 KB
testcase_02 AC 44 ms
53,760 KB
testcase_03 AC 44 ms
53,760 KB
testcase_04 AC 44 ms
53,632 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 45 ms
53,888 KB
testcase_08 WA -
testcase_09 AC 46 ms
53,504 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 57 ms
61,952 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 45 ms
53,632 KB
testcase_16 AC 46 ms
53,632 KB
testcase_17 AC 45 ms
53,888 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 277 ms
76,928 KB
testcase_21 WA -
testcase_22 AC 66 ms
66,304 KB
testcase_23 AC 45 ms
53,632 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 65 ms
66,304 KB
testcase_32 AC 50 ms
54,016 KB
testcase_33 AC 66 ms
66,432 KB
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

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]%mod)
0