結果

問題 No.1731 Product of Subsequence
ユーザー tamatotamato
提出日時 2021-11-05 21:52:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 869 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 90,624 KB
最終ジャッジ日時 2024-04-24 05:39:36
合計ジャッジ時間 13,081 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,021 ms
89,344 KB
testcase_01 AC 37 ms
52,480 KB
testcase_02 AC 35 ms
52,736 KB
testcase_03 AC 40 ms
58,112 KB
testcase_04 AC 36 ms
52,736 KB
testcase_05 AC 44 ms
59,520 KB
testcase_06 AC 48 ms
60,544 KB
testcase_07 AC 40 ms
58,368 KB
testcase_08 AC 86 ms
75,904 KB
testcase_09 WA -
testcase_10 AC 1,245 ms
89,984 KB
testcase_11 AC 1,020 ms
86,656 KB
testcase_12 AC 49 ms
62,208 KB
testcase_13 AC 107 ms
76,800 KB
testcase_14 AC 924 ms
85,248 KB
testcase_15 AC 35 ms
52,736 KB
testcase_16 WA -
testcase_17 AC 35 ms
52,736 KB
testcase_18 AC 824 ms
84,224 KB
testcase_19 AC 104 ms
76,800 KB
testcase_20 AC 694 ms
81,536 KB
testcase_21 AC 1,226 ms
88,832 KB
testcase_22 AC 56 ms
65,024 KB
testcase_23 WA -
testcase_24 AC 79 ms
71,296 KB
testcase_25 AC 66 ms
68,224 KB
testcase_26 AC 275 ms
77,184 KB
testcase_27 AC 338 ms
77,056 KB
testcase_28 AC 576 ms
79,360 KB
testcase_29 AC 295 ms
77,312 KB
testcase_30 AC 1,079 ms
90,624 KB
testcase_31 AC 54 ms
65,280 KB
testcase_32 WA -
testcase_33 AC 55 ms
64,512 KB
testcase_34 AC 168 ms
77,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from math import gcd
    input = sys.stdin.readline

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    div = []
    for d in range(1, K+1):
        if d * d > K:
            break
        if K % d == 0:
            div.append(d)
            div.append(K // d)
    if div[-1] == div[-2]:
        div.pop()

    dp = {}
    dp[1] = 1
    for a in A:
        dp_new = {}
        for j in dp:
            if j not in dp_new:
                dp_new[j] = 0
            dp_new[j] = (dp_new[j] + dp[j])%mod
            j_new = gcd(j * a, K)
            if j_new not in dp_new:
                dp_new[j_new] = 0
            dp_new[j_new] = (dp_new[j_new] + dp[j])%mod
        dp = dp_new
    if K not in dp:
        dp[K] = 0
    print(dp[K])


if __name__ == '__main__':
    main()
0