結果

問題 No.1731 Product of Subsequence
ユーザー 👑 rin204rin204
提出日時 2022-01-25 01:57:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,195 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 82,664 KB
実行使用メモリ 88,632 KB
最終ジャッジ日時 2024-04-25 17:57:17
合計ジャッジ時間 12,591 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 980 ms
87,560 KB
testcase_01 AC 34 ms
53,852 KB
testcase_02 AC 35 ms
53,088 KB
testcase_03 AC 35 ms
52,468 KB
testcase_04 AC 33 ms
52,940 KB
testcase_05 AC 41 ms
60,808 KB
testcase_06 AC 42 ms
61,336 KB
testcase_07 AC 33 ms
53,680 KB
testcase_08 AC 77 ms
75,956 KB
testcase_09 AC 35 ms
52,524 KB
testcase_10 AC 1,173 ms
87,888 KB
testcase_11 AC 983 ms
85,284 KB
testcase_12 AC 43 ms
62,504 KB
testcase_13 AC 95 ms
76,632 KB
testcase_14 AC 873 ms
83,740 KB
testcase_15 AC 35 ms
52,800 KB
testcase_16 AC 34 ms
52,336 KB
testcase_17 AC 34 ms
53,152 KB
testcase_18 AC 777 ms
82,708 KB
testcase_19 AC 94 ms
76,832 KB
testcase_20 AC 666 ms
80,616 KB
testcase_21 AC 1,195 ms
87,132 KB
testcase_22 AC 47 ms
64,492 KB
testcase_23 AC 34 ms
52,200 KB
testcase_24 AC 71 ms
74,000 KB
testcase_25 AC 57 ms
69,848 KB
testcase_26 AC 260 ms
76,956 KB
testcase_27 AC 333 ms
77,092 KB
testcase_28 AC 568 ms
79,072 KB
testcase_29 AC 275 ms
77,036 KB
testcase_30 AC 1,043 ms
88,632 KB
testcase_31 AC 47 ms
64,684 KB
testcase_32 AC 34 ms
52,860 KB
testcase_33 AC 47 ms
64,872 KB
testcase_34 AC 155 ms
76,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
MOD = 10 ** 9 + 7

n, K = map(int, input().split())
if K == 1:
    print(pow(2, n, MOD) - 1)
    exit()
    
A = list(map(int, input().split()))
dp = {1:1}
for a in A:
    dp2 = {}
    for k, v in dp.items():
        dp2[k] = dp2.get(k, 0) + v
        dp2[k] %= MOD
        g = gcd(k * a, K)
        dp2[g] = dp2.get(g, 0) + v
        dp2[g] %= MOD
    dp = dp2
print(dp.get(K, 0))
    
0