結果

問題 No.1731 Product of Subsequence
ユーザー gr1msl3ygr1msl3y
提出日時 2021-11-05 21:52:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 921 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 82,316 KB
最終ジャッジ日時 2024-04-25 17:20:45
合計ジャッジ時間 10,861 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 805 ms
81,824 KB
testcase_01 AC 42 ms
54,060 KB
testcase_02 AC 42 ms
55,032 KB
testcase_03 AC 42 ms
54,416 KB
testcase_04 AC 42 ms
54,408 KB
testcase_05 AC 51 ms
63,148 KB
testcase_06 AC 54 ms
65,276 KB
testcase_07 AC 43 ms
54,964 KB
testcase_08 AC 97 ms
76,556 KB
testcase_09 AC 47 ms
60,648 KB
testcase_10 AC 921 ms
81,560 KB
testcase_11 AC 737 ms
81,280 KB
testcase_12 AC 59 ms
68,152 KB
testcase_13 AC 104 ms
77,228 KB
testcase_14 AC 651 ms
79,076 KB
testcase_15 AC 41 ms
54,304 KB
testcase_16 AC 42 ms
54,236 KB
testcase_17 AC 42 ms
55,172 KB
testcase_18 AC 667 ms
80,376 KB
testcase_19 AC 104 ms
77,060 KB
testcase_20 AC 570 ms
79,416 KB
testcase_21 AC 910 ms
82,316 KB
testcase_22 AC 62 ms
68,112 KB
testcase_23 AC 45 ms
61,104 KB
testcase_24 AC 94 ms
77,196 KB
testcase_25 AC 86 ms
77,004 KB
testcase_26 AC 210 ms
77,500 KB
testcase_27 AC 263 ms
77,036 KB
testcase_28 AC 437 ms
78,028 KB
testcase_29 AC 226 ms
77,276 KB
testcase_30 AC 868 ms
81,668 KB
testcase_31 AC 59 ms
69,492 KB
testcase_32 AC 45 ms
60,648 KB
testcase_33 AC 61 ms
68,408 KB
testcase_34 AC 142 ms
77,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from math import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9+7
if K == 1:
    print((pow(2, N, MOD)-1) % MOD)
    exit()

dp = defaultdict(int)
dp[1] = 1
for a in A:
    a = gcd(K, a)
    ndp = defaultdict(int)
    for k in dp:
        ndp[k] += dp[k]
        ndp[k] %= MOD
        v = gcd(a*k, K)
        if v == K:
            v = 0
        ndp[v] += dp[k]
        ndp[v] %= MOD
    dp = ndp

print(dp[0])
0