結果

問題 No.1731 Product of Subsequence
ユーザー HydruHydru
提出日時 2021-11-06 13:23:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,058 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 179,012 KB
最終ジャッジ日時 2024-04-25 17:41:08
合計ジャッジ時間 11,737 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 910 ms
175,184 KB
testcase_01 AC 39 ms
54,056 KB
testcase_02 AC 39 ms
55,692 KB
testcase_03 AC 39 ms
54,692 KB
testcase_04 AC 37 ms
55,448 KB
testcase_05 AC 48 ms
65,096 KB
testcase_06 AC 54 ms
66,516 KB
testcase_07 AC 42 ms
55,764 KB
testcase_08 AC 95 ms
78,128 KB
testcase_09 AC 39 ms
54,068 KB
testcase_10 AC 1,058 ms
175,104 KB
testcase_11 AC 878 ms
167,888 KB
testcase_12 AC 57 ms
68,900 KB
testcase_13 AC 99 ms
78,120 KB
testcase_14 AC 778 ms
156,568 KB
testcase_15 AC 39 ms
53,976 KB
testcase_16 AC 39 ms
54,356 KB
testcase_17 AC 39 ms
55,396 KB
testcase_18 AC 768 ms
155,680 KB
testcase_19 AC 98 ms
78,128 KB
testcase_20 AC 647 ms
144,356 KB
testcase_21 AC 1,021 ms
179,012 KB
testcase_22 AC 60 ms
70,608 KB
testcase_23 AC 38 ms
54,004 KB
testcase_24 AC 90 ms
78,276 KB
testcase_25 AC 82 ms
78,164 KB
testcase_26 AC 231 ms
94,104 KB
testcase_27 AC 293 ms
97,936 KB
testcase_28 AC 492 ms
117,816 KB
testcase_29 AC 239 ms
94,140 KB
testcase_30 AC 994 ms
174,844 KB
testcase_31 AC 62 ms
70,380 KB
testcase_32 AC 37 ms
54,136 KB
testcase_33 AC 59 ms
70,900 KB
testcase_34 AC 140 ms
83,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import exit
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()))
ans=0

dp=[defaultdict(int) for _ in range(n+1)]
dp[0][1]=1
for i in range(1,n+1):
    for j in dp[i-1]:
        dp[i][j]+=dp[i-1][j]
        dp[i][j]%=mod

        ai=A[i-1]
        g=gcd(j*ai,k)
        dp[i][g]+=dp[i-1][j]
        dp[i][g]%=mod
ans=dp[n][k]
print(ans)
0