結果

問題 No.1731 Product of Subsequence
ユーザー gr1msl3ygr1msl3y
提出日時 2021-11-05 21:51:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 444 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 81,920 KB
最終ジャッジ日時 2024-04-24 05:37:19
合計ジャッジ時間 10,860 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 43 ms
53,888 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 43 ms
54,400 KB
testcase_08 WA -
testcase_09 AC 45 ms
60,160 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 60 ms
66,944 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 40 ms
53,888 KB
testcase_16 AC 40 ms
53,760 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 46 ms
60,032 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 46 ms
60,032 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

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
        ndp[gcd(a*k, K)] += dp[k]
        ndp[gcd(a*k, K)] %= MOD
    dp = ndp

print(dp[0])
0