結果

問題 No.1731 Product of Subsequence
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-07 03:02:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 731 ms / 2,000 ms
コード長 450 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 82,548 KB
実行使用メモリ 82,340 KB
最終ジャッジ日時 2024-04-25 17:45:40
合計ジャッジ時間 9,171 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 647 ms
81,848 KB
testcase_01 AC 38 ms
54,260 KB
testcase_02 AC 37 ms
55,276 KB
testcase_03 AC 37 ms
54,520 KB
testcase_04 AC 35 ms
55,616 KB
testcase_05 AC 45 ms
63,552 KB
testcase_06 AC 49 ms
64,176 KB
testcase_07 AC 37 ms
54,712 KB
testcase_08 AC 81 ms
76,680 KB
testcase_09 AC 52 ms
67,800 KB
testcase_10 AC 731 ms
81,508 KB
testcase_11 AC 628 ms
80,576 KB
testcase_12 AC 55 ms
68,332 KB
testcase_13 AC 82 ms
77,200 KB
testcase_14 AC 538 ms
79,876 KB
testcase_15 AC 38 ms
55,240 KB
testcase_16 AC 37 ms
54,764 KB
testcase_17 AC 36 ms
55,636 KB
testcase_18 AC 529 ms
78,784 KB
testcase_19 AC 84 ms
76,988 KB
testcase_20 AC 442 ms
78,048 KB
testcase_21 AC 720 ms
81,516 KB
testcase_22 AC 57 ms
68,432 KB
testcase_23 AC 54 ms
67,848 KB
testcase_24 AC 80 ms
77,280 KB
testcase_25 AC 70 ms
74,080 KB
testcase_26 AC 179 ms
77,352 KB
testcase_27 AC 218 ms
77,056 KB
testcase_28 AC 352 ms
77,928 KB
testcase_29 AC 183 ms
77,264 KB
testcase_30 AC 723 ms
82,340 KB
testcase_31 AC 56 ms
69,896 KB
testcase_32 AC 56 ms
67,760 KB
testcase_33 AC 58 ms
69,316 KB
testcase_34 AC 112 ms
77,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7
from collections import defaultdict
import math

dp = defaultdict(lambda: 0)
dp[1] = 1
for a in A:
    a = math.gcd(a, k)
    nx = defaultdict(lambda: 0)
    for j, v in dp.items():
        nx[j] += v
        nx[j] %= mod
        g = math.gcd(j*a, k)
        nx[g] += v
        nx[g] %= mod
    dp = nx

if k == 1:
    print((dp[k]-1)%mod)
else:
    print(dp[k]%mod)
0