結果

問題 No.1731 Product of Subsequence
ユーザー 👑 H20H20
提出日時 2021-12-08 10:45:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 764 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 80,764 KB
最終ジャッジ日時 2024-04-25 17:54:56
合計ジャッジ時間 9,560 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 695 ms
80,764 KB
testcase_01 AC 41 ms
55,488 KB
testcase_02 AC 41 ms
53,952 KB
testcase_03 AC 40 ms
54,176 KB
testcase_04 AC 41 ms
55,040 KB
testcase_05 AC 50 ms
63,256 KB
testcase_06 AC 51 ms
64,156 KB
testcase_07 AC 43 ms
54,508 KB
testcase_08 AC 84 ms
76,320 KB
testcase_09 AC 64 ms
70,664 KB
testcase_10 AC 764 ms
80,344 KB
testcase_11 AC 614 ms
79,748 KB
testcase_12 AC 65 ms
71,156 KB
testcase_13 AC 79 ms
76,768 KB
testcase_14 AC 580 ms
79,108 KB
testcase_15 AC 42 ms
54,956 KB
testcase_16 AC 41 ms
54,372 KB
testcase_17 AC 41 ms
54,200 KB
testcase_18 AC 619 ms
79,336 KB
testcase_19 AC 82 ms
76,740 KB
testcase_20 AC 506 ms
78,520 KB
testcase_21 AC 719 ms
80,528 KB
testcase_22 AC 66 ms
70,856 KB
testcase_23 AC 67 ms
71,948 KB
testcase_24 AC 79 ms
76,800 KB
testcase_25 AC 69 ms
74,220 KB
testcase_26 AC 170 ms
77,028 KB
testcase_27 AC 214 ms
76,860 KB
testcase_28 AC 361 ms
77,192 KB
testcase_29 AC 180 ms
76,952 KB
testcase_30 AC 701 ms
80,084 KB
testcase_31 AC 64 ms
71,244 KB
testcase_32 AC 65 ms
70,384 KB
testcase_33 AC 65 ms
70,184 KB
testcase_34 AC 104 ms
76,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))
mod = 10**9+7
for i in range(N):
    A[i] = math.gcd(A[i],K)

DP = collections.defaultdict(int)
DP[1]=1
for a in A:
    NDP = collections.defaultdict(int)
    CDP = DP.copy()

    for k,v in CDP.items():
        gcd = math.gcd(K,a*k)
        NDP[gcd]=(NDP[gcd]+DP[k])%mod
        NDP[k]=(NDP[k]+DP[k])%mod
    DP = NDP
if K==1:
    DP[K]=(DP[K]-1)%mod
print(DP[K])
0