結果

問題 No.2313 Product of Subsequence (hard)
ユーザー sotanishysotanishy
提出日時 2023-05-24 21:39:16
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 833 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 139,180 KB
最終ジャッジ日時 2023-08-25 13:42:29
合計ジャッジ時間 31,409 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,096 KB
testcase_01 AC 59 ms
71,400 KB
testcase_02 AC 59 ms
71,100 KB
testcase_03 AC 69 ms
76,344 KB
testcase_04 AC 69 ms
76,356 KB
testcase_05 AC 73 ms
76,632 KB
testcase_06 AC 70 ms
76,256 KB
testcase_07 AC 69 ms
76,576 KB
testcase_08 AC 271 ms
127,672 KB
testcase_09 AC 160 ms
96,268 KB
testcase_10 AC 262 ms
128,056 KB
testcase_11 AC 147 ms
93,760 KB
testcase_12 AC 283 ms
127,156 KB
testcase_13 AC 2,927 ms
134,380 KB
testcase_14 AC 2,973 ms
133,372 KB
testcase_15 AC 2,966 ms
133,988 KB
testcase_16 AC 2,965 ms
134,188 KB
testcase_17 AC 2,816 ms
133,940 KB
testcase_18 AC 2,790 ms
133,416 KB
testcase_19 AC 2,797 ms
133,856 KB
testcase_20 AC 3,096 ms
133,392 KB
testcase_21 AC 65 ms
75,192 KB
testcase_22 AC 63 ms
71,244 KB
testcase_23 AC 60 ms
71,480 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 2,760 ms
139,180 KB
testcase_28 AC 250 ms
132,176 KB
testcase_29 AC 275 ms
132,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
import sys
input = sys.stdin.readline


def divisor(n):
    divisors = []
    i = 1
    while i * i < n:
        if n % i == 0:
            divisors.append(i)
            divisors.append(n // i)
        i += 1
    if i * i == n:
        divisors.append(i)
    divisors.sort()
    return divisors


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

if K == 1:
    print((pow(2, N, mod) - 1) % mod)
    exit()

div = divisor(K)
idx = {d: i for i, d in enumerate(div)}
D = len(div)

prod_idx = [[0]*D for _ in range(D)]
for i in range(D):
    for j in range(D):
        prod_idx[i][j] = idx[gcd(div[i]*div[j], K)]

mod = 998244353
dp = [0]*D
dp[0] = 1

for x in A:
    i = idx[gcd(x, K)]

    for j in range(D)[::-1]:
        k = prod_idx[i][j]
        dp[k] = (dp[k]+dp[j]) % mod
print(dp[-1])
0