結果

問題 No.1731 Product of Subsequence
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-07 03:01:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,294 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 89,092 KB
最終ジャッジ日時 2024-04-25 17:45:31
合計ジャッジ時間 13,702 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,063 ms
88,544 KB
testcase_01 AC 40 ms
55,212 KB
testcase_02 AC 39 ms
54,936 KB
testcase_03 AC 38 ms
55,504 KB
testcase_04 AC 37 ms
54,504 KB
testcase_05 AC 48 ms
64,064 KB
testcase_06 AC 51 ms
65,192 KB
testcase_07 AC 38 ms
55,556 KB
testcase_08 AC 90 ms
76,544 KB
testcase_09 AC 51 ms
67,028 KB
testcase_10 AC 1,294 ms
84,424 KB
testcase_11 AC 1,076 ms
86,004 KB
testcase_12 AC 53 ms
68,124 KB
testcase_13 AC 120 ms
77,652 KB
testcase_14 AC 985 ms
81,616 KB
testcase_15 AC 40 ms
54,812 KB
testcase_16 AC 38 ms
54,328 KB
testcase_17 AC 39 ms
54,068 KB
testcase_18 AC 839 ms
83,580 KB
testcase_19 AC 117 ms
77,240 KB
testcase_20 AC 716 ms
81,072 KB
testcase_21 AC 1,240 ms
87,728 KB
testcase_22 AC 57 ms
70,400 KB
testcase_23 AC 52 ms
67,444 KB
testcase_24 AC 88 ms
77,160 KB
testcase_25 AC 72 ms
73,900 KB
testcase_26 AC 282 ms
78,156 KB
testcase_27 AC 351 ms
78,096 KB
testcase_28 AC 597 ms
79,668 KB
testcase_29 AC 303 ms
77,524 KB
testcase_30 AC 1,105 ms
89,092 KB
testcase_31 AC 56 ms
70,112 KB
testcase_32 AC 52 ms
66,872 KB
testcase_33 AC 58 ms
69,432 KB
testcase_34 AC 179 ms
77,848 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:
    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