結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 917 ms
174,176 KB
testcase_01 AC 74 ms
71,228 KB
testcase_02 AC 72 ms
71,224 KB
testcase_03 AC 71 ms
71,284 KB
testcase_04 AC 71 ms
70,968 KB
testcase_05 AC 81 ms
76,356 KB
testcase_06 AC 85 ms
76,464 KB
testcase_07 AC 73 ms
71,320 KB
testcase_08 WA -
testcase_09 AC 72 ms
71,492 KB
testcase_10 WA -
testcase_11 AC 845 ms
166,484 KB
testcase_12 AC 89 ms
76,744 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 71 ms
71,428 KB
testcase_16 AC 72 ms
71,216 KB
testcase_17 AC 71 ms
70,976 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 92 ms
77,132 KB
testcase_23 AC 73 ms
71,508 KB
testcase_24 AC 117 ms
78,676 KB
testcase_25 WA -
testcase_26 AC 243 ms
96,356 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 997 ms
178,980 KB
testcase_31 AC 93 ms
76,804 KB
testcase_32 AC 72 ms
70,904 KB
testcase_33 AC 93 ms
76,892 KB
testcase_34 AC 166 ms
84,216 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