結果

問題 No.1731 Product of Subsequence
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-07 03:01:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,355 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 1,202 ms
コンパイル使用メモリ 86,576 KB
実行使用メモリ 90,448 KB
最終ジャッジ日時 2023-08-07 23:34:12
合計ジャッジ時間 17,214 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,127 ms
90,448 KB
testcase_01 AC 101 ms
71,640 KB
testcase_02 AC 101 ms
71,868 KB
testcase_03 AC 100 ms
71,468 KB
testcase_04 AC 101 ms
71,540 KB
testcase_05 AC 112 ms
77,160 KB
testcase_06 AC 117 ms
77,408 KB
testcase_07 AC 99 ms
71,376 KB
testcase_08 AC 150 ms
77,848 KB
testcase_09 AC 119 ms
77,672 KB
testcase_10 AC 1,355 ms
85,460 KB
testcase_11 AC 1,135 ms
87,060 KB
testcase_12 AC 120 ms
77,928 KB
testcase_13 AC 179 ms
79,224 KB
testcase_14 AC 1,014 ms
83,260 KB
testcase_15 AC 96 ms
71,640 KB
testcase_16 AC 98 ms
71,644 KB
testcase_17 AC 98 ms
71,852 KB
testcase_18 AC 887 ms
84,984 KB
testcase_19 AC 172 ms
78,768 KB
testcase_20 AC 785 ms
82,352 KB
testcase_21 AC 1,333 ms
89,492 KB
testcase_22 AC 116 ms
77,892 KB
testcase_23 AC 114 ms
78,056 KB
testcase_24 AC 146 ms
78,148 KB
testcase_25 AC 133 ms
78,204 KB
testcase_26 AC 352 ms
78,936 KB
testcase_27 AC 422 ms
79,196 KB
testcase_28 AC 675 ms
80,684 KB
testcase_29 AC 373 ms
79,040 KB
testcase_30 AC 1,156 ms
90,060 KB
testcase_31 AC 116 ms
77,892 KB
testcase_32 AC 110 ms
78,228 KB
testcase_33 AC 115 ms
78,084 KB
testcase_34 AC 241 ms
79,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7
from collections import defaultdict
import math

dp = defaultdict(lambda: 0)
dp[1] = 1
for a in A:
    nx = defaultdict(lambda: 0)
    for j, v in dp.items():
        nx[j] += v
        nx[j] %= mod
        g = math.gcd(j*a, k)
        nx[g] += v
        nx[g] %= mod
    dp = nx

if k == 1:
    print((dp[k]-1)%mod)
else:
    print(dp[k]%mod)
0