結果

問題 No.1731 Product of Subsequence
ユーザー 👑 H20H20
提出日時 2021-12-08 10:38:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 458 bytes
コンパイル時間 753 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 82,068 KB
最終ジャッジ日時 2023-09-23 02:35:50
合計ジャッジ時間 13,963 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 777 ms
81,348 KB
testcase_01 AC 93 ms
71,724 KB
testcase_02 AC 92 ms
71,688 KB
testcase_03 AC 92 ms
71,648 KB
testcase_04 AC 94 ms
71,608 KB
testcase_05 AC 105 ms
77,252 KB
testcase_06 AC 104 ms
77,608 KB
testcase_07 AC 95 ms
71,588 KB
testcase_08 AC 133 ms
77,368 KB
testcase_09 WA -
testcase_10 AC 834 ms
82,040 KB
testcase_11 AC 707 ms
80,924 KB
testcase_12 AC 122 ms
78,188 KB
testcase_13 AC 136 ms
78,252 KB
testcase_14 AC 658 ms
80,716 KB
testcase_15 AC 93 ms
71,548 KB
testcase_16 WA -
testcase_17 AC 94 ms
71,972 KB
testcase_18 AC 697 ms
80,476 KB
testcase_19 AC 135 ms
78,340 KB
testcase_20 AC 537 ms
80,256 KB
testcase_21 AC 821 ms
82,068 KB
testcase_22 AC 126 ms
77,968 KB
testcase_23 WA -
testcase_24 AC 135 ms
78,304 KB
testcase_25 AC 129 ms
78,076 KB
testcase_26 AC 226 ms
78,560 KB
testcase_27 AC 270 ms
78,344 KB
testcase_28 AC 432 ms
79,024 KB
testcase_29 AC 236 ms
78,312 KB
testcase_30 AC 812 ms
81,848 KB
testcase_31 AC 124 ms
78,200 KB
testcase_32 WA -
testcase_33 AC 125 ms
77,992 KB
testcase_34 AC 160 ms
78,468 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
    for k,v in CDP.items():
        NDP[k]=(NDP[k]+DP[k])%mod
    DP = NDP
print(DP[K])
0