結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 951 ms
173,852 KB
testcase_01 AC 73 ms
71,220 KB
testcase_02 AC 74 ms
71,112 KB
testcase_03 AC 74 ms
71,136 KB
testcase_04 AC 73 ms
71,268 KB
testcase_05 AC 81 ms
76,580 KB
testcase_06 AC 82 ms
76,732 KB
testcase_07 AC 73 ms
70,968 KB
testcase_08 AC 120 ms
78,576 KB
testcase_09 AC 73 ms
71,264 KB
testcase_10 AC 1,038 ms
179,628 KB
testcase_11 AC 842 ms
166,180 KB
testcase_12 AC 90 ms
76,968 KB
testcase_13 AC 125 ms
78,408 KB
testcase_14 AC 774 ms
158,596 KB
testcase_15 AC 72 ms
71,196 KB
testcase_16 AC 72 ms
71,344 KB
testcase_17 AC 72 ms
71,304 KB
testcase_18 AC 795 ms
158,120 KB
testcase_19 AC 122 ms
78,820 KB
testcase_20 AC 679 ms
145,512 KB
testcase_21 AC 1,013 ms
178,884 KB
testcase_22 AC 96 ms
76,776 KB
testcase_23 AC 73 ms
71,380 KB
testcase_24 AC 120 ms
78,532 KB
testcase_25 AC 111 ms
78,724 KB
testcase_26 AC 246 ms
96,352 KB
testcase_27 AC 310 ms
100,600 KB
testcase_28 AC 498 ms
117,272 KB
testcase_29 AC 265 ms
96,360 KB
testcase_30 AC 1,002 ms
178,944 KB
testcase_31 AC 95 ms
76,888 KB
testcase_32 AC 74 ms
71,284 KB
testcase_33 AC 95 ms
76,892 KB
testcase_34 AC 168 ms
84,536 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]%mod)

0