結果

問題 No.2313 Product of Subsequence (hard)
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-22 12:02:40
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 625 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 145,184 KB
最終ジャッジ日時 2023-11-22 12:02:55
合計ジャッジ時間 14,657 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
60,392 KB
testcase_01 AC 38 ms
53,588 KB
testcase_02 AC 38 ms
53,588 KB
testcase_03 AC 57 ms
66,692 KB
testcase_04 AC 61 ms
70,756 KB
testcase_05 AC 94 ms
75,780 KB
testcase_06 AC 52 ms
64,612 KB
testcase_07 AC 69 ms
74,116 KB
testcase_08 AC 2,570 ms
124,536 KB
testcase_09 AC 291 ms
97,428 KB
testcase_10 AC 1,156 ms
133,980 KB
testcase_11 AC 335 ms
95,132 KB
testcase_12 AC 856 ms
133,236 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
def md(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
    
    
P = md(K)
n = len(P)
P.sort()
dp = [0]*n
dp[0] = 1
inv = {p:i for i,p in enumerate(P)}
for a in A:
    
    for i in range(n-1,-1,-1):
        
        d = math.gcd(K,a*P[i])
        dp[inv[d]] = (dp[i] + dp[inv[d]])%mod

print(dp[-1]%mod)
0