結果

問題 No.1731 Product of Subsequence
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-09-16 18:31:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 429 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 179,824 KB
最終ジャッジ日時 2023-08-23 12:29:54
合計ジャッジ時間 13,462 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 898 ms
173,804 KB
testcase_01 AC 72 ms
71,288 KB
testcase_02 AC 71 ms
71,200 KB
testcase_03 AC 71 ms
71,488 KB
testcase_04 AC 70 ms
71,488 KB
testcase_05 AC 79 ms
76,496 KB
testcase_06 AC 82 ms
76,700 KB
testcase_07 AC 70 ms
71,388 KB
testcase_08 WA -
testcase_09 AC 70 ms
71,244 KB
testcase_10 WA -
testcase_11 AC 816 ms
166,248 KB
testcase_12 AC 89 ms
76,688 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 70 ms
71,288 KB
testcase_16 AC 71 ms
71,392 KB
testcase_17 AC 69 ms
70,984 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 96 ms
76,912 KB
testcase_23 AC 73 ms
71,300 KB
testcase_24 AC 121 ms
78,744 KB
testcase_25 WA -
testcase_26 AC 238 ms
96,492 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 956 ms
178,996 KB
testcase_31 AC 90 ms
76,764 KB
testcase_32 AC 70 ms
71,360 KB
testcase_33 AC 90 ms
76,956 KB
testcase_34 AC 163 ms
84,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


from math import gcd
from _collections import defaultdict
mod=10**9+7
n,k=map(int,input().split())
if k==1:
    print((2**n-1)%mod)
    exit()
a=[0]+list(map(int,input().split()))
for i in range(1,n+1):
    a[i]=gcd(a[i],k)
dp=[defaultdict(int) for i in range(n+3)]
dp[0][1]=1
for i in range(n):
    for j in dp[i]:
        dp[i][j]%=mod
        dp[i+1][j]+=dp[i][j]
        dp[i+1][gcd(k,j*a[i+1])]+=dp[i][j]
print(dp[n][k])

0