結果

問題 No.1731 Product of Subsequence
ユーザー irumo8202irumo8202
提出日時 2022-01-29 12:54:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 466 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 77,372 KB
最終ジャッジ日時 2024-04-25 17:57:27
合計ジャッジ時間 6,458 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 429 ms
77,152 KB
testcase_01 AC 41 ms
55,884 KB
testcase_02 AC 41 ms
54,608 KB
testcase_03 AC 40 ms
55,504 KB
testcase_04 AC 40 ms
55,520 KB
testcase_05 AC 47 ms
62,376 KB
testcase_06 AC 47 ms
62,284 KB
testcase_07 AC 44 ms
55,132 KB
testcase_08 AC 62 ms
68,120 KB
testcase_09 AC 57 ms
66,032 KB
testcase_10 AC 466 ms
77,160 KB
testcase_11 AC 403 ms
77,036 KB
testcase_12 AC 57 ms
66,840 KB
testcase_13 AC 62 ms
68,188 KB
testcase_14 AC 338 ms
77,116 KB
testcase_15 AC 43 ms
54,436 KB
testcase_16 AC 40 ms
54,096 KB
testcase_17 AC 40 ms
54,928 KB
testcase_18 AC 334 ms
77,204 KB
testcase_19 AC 60 ms
68,544 KB
testcase_20 AC 274 ms
77,072 KB
testcase_21 AC 426 ms
77,372 KB
testcase_22 AC 57 ms
66,496 KB
testcase_23 AC 58 ms
66,032 KB
testcase_24 AC 60 ms
68,388 KB
testcase_25 AC 56 ms
67,464 KB
testcase_26 AC 117 ms
76,800 KB
testcase_27 AC 139 ms
76,664 KB
testcase_28 AC 233 ms
76,736 KB
testcase_29 AC 120 ms
76,948 KB
testcase_30 AC 416 ms
77,212 KB
testcase_31 AC 55 ms
67,332 KB
testcase_32 AC 55 ms
67,084 KB
testcase_33 AC 55 ms
66,620 KB
testcase_34 AC 71 ms
74,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
from collections import defaultdict

N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

dp = defaultdict(int)
dp[1] = 1

for a in A:
    m = math.gcd(a, K)
    for n, cnt in dp.copy().items():
        g = math.gcd(n * m, K)
        dp[g] += cnt
        dp[g] %= MOD

print(dp[K] - (K == 1))
0