結果

問題 No.2313 Product of Subsequence (hard)
ユーザー dangodango
提出日時 2023-08-01 19:14:51
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 678 bytes
コンパイル時間 2,482 ms
コンパイル使用メモリ 86,736 KB
実行使用メモリ 143,564 KB
最終ジャッジ日時 2023-08-24 16:50:04
合計ジャッジ時間 45,322 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,228 KB
testcase_01 AC 76 ms
71,200 KB
testcase_02 AC 78 ms
71,304 KB
testcase_03 AC 93 ms
76,544 KB
testcase_04 AC 91 ms
76,360 KB
testcase_05 AC 93 ms
76,436 KB
testcase_06 AC 88 ms
76,744 KB
testcase_07 AC 90 ms
76,396 KB
testcase_08 AC 331 ms
132,664 KB
testcase_09 AC 201 ms
97,080 KB
testcase_10 AC 310 ms
132,376 KB
testcase_11 AC 177 ms
94,144 KB
testcase_12 AC 345 ms
138,856 KB
testcase_13 AC 3,932 ms
143,564 KB
testcase_14 AC 3,941 ms
141,804 KB
testcase_15 AC 3,906 ms
142,012 KB
testcase_16 AC 3,927 ms
143,276 KB
testcase_17 AC 3,767 ms
140,976 KB
testcase_18 TLE -
testcase_19 AC 3,803 ms
141,728 KB
testcase_20 AC 3,736 ms
141,096 KB
testcase_21 AC 78 ms
75,692 KB
testcase_22 AC 74 ms
71,368 KB
testcase_23 AC 76 ms
71,024 KB
testcase_24 AC 74 ms
71,284 KB
testcase_25 AC 270 ms
132,588 KB
testcase_26 AC 198 ms
107,088 KB
testcase_27 AC 3,592 ms
142,328 KB
testcase_28 AC 299 ms
136,572 KB
testcase_29 AC 327 ms
141,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math, sys
N, K = map(int, sys.stdin.readline().split())
*A, = map(int, sys.stdin.readline().split())
MOD = 998244353
div = []
for I in range(1, K + 1):
    if I ** 2 > K: break
    if K % I == 0:
        div.append(I)
        if I ** 2 < K:
            div.append(K // I)
div.sort()
ZA = {V:I for I, V in enumerate(div)}
L = len(ZA)
NX = [[0] * L for _ in range(L)]
for I in range(L):
    for J in range(1, L):
        NX[I][J] = NX[J][I] = ZA[math.gcd(div[I] * div[J], K)]
DP = [0] * L
DP[0] = 1
for I in A:
    ID = ZA[math.gcd(I, K)]
    for R in range(L)[::-1]:
        NID = NX[ID][R]
        V = DP[R]
        DP[NID] = (DP[NID] + V) % MOD
print(DP[-1] - (K == 1))
0