結果

問題 No.1731 Product of Subsequence
ユーザー rlangevinrlangevin
提出日時 2023-02-02 21:13:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,902 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 88,784 KB
最終ジャッジ日時 2023-09-15 02:19:51
合計ジャッジ時間 20,836 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,493 ms
88,784 KB
testcase_01 AC 94 ms
71,716 KB
testcase_02 AC 98 ms
71,840 KB
testcase_03 AC 93 ms
71,520 KB
testcase_04 AC 94 ms
71,864 KB
testcase_05 AC 110 ms
77,440 KB
testcase_06 AC 115 ms
77,532 KB
testcase_07 AC 97 ms
71,972 KB
testcase_08 AC 159 ms
77,980 KB
testcase_09 AC 116 ms
78,212 KB
testcase_10 AC 1,888 ms
87,320 KB
testcase_11 AC 1,571 ms
84,896 KB
testcase_12 AC 118 ms
78,076 KB
testcase_13 AC 195 ms
79,044 KB
testcase_14 AC 1,421 ms
85,188 KB
testcase_15 AC 96 ms
71,720 KB
testcase_16 AC 95 ms
71,768 KB
testcase_17 AC 94 ms
71,724 KB
testcase_18 AC 1,281 ms
86,092 KB
testcase_19 AC 187 ms
78,844 KB
testcase_20 AC 1,084 ms
83,136 KB
testcase_21 AC 1,902 ms
88,468 KB
testcase_22 AC 119 ms
78,116 KB
testcase_23 AC 118 ms
78,236 KB
testcase_24 AC 155 ms
78,060 KB
testcase_25 AC 135 ms
78,308 KB
testcase_26 AC 454 ms
79,360 KB
testcase_27 AC 551 ms
79,432 KB
testcase_28 AC 917 ms
80,472 KB
testcase_29 AC 475 ms
79,360 KB
testcase_30 AC 1,572 ms
86,192 KB
testcase_31 AC 120 ms
77,952 KB
testcase_32 AC 116 ms
77,964 KB
testcase_33 AC 124 ms
77,916 KB
testcase_34 AC 297 ms
78,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from math import gcd

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

pre = defaultdict(int)
pre[0] = 1
for i in range(N):
    dp = defaultdict(int)
    for k, v in pre.items():
        dp[k] += v
        if k == 0:
            na = A[i]
        else:
            na = A[i] * k
        dp[gcd(na, K)] += v
        dp[k] %= mod
        dp[gcd(na, K)] %= mod
                 
    pre, dp = dp, pre
print(pre[K])       
0