結果

問題 No.1529 Constant Lcm
ユーザー ntuda
提出日時 2025-02-04 21:39:58
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 672 bytes
コンパイル時間 1,651 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 155,016 KB
最終ジャッジ日時 2025-02-04 21:41:05
合計ジャッジ時間 66,510 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 TLE * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def n_fact(N):
    c = collections.Counter(prime_factorize(N))
    return c

from collections import defaultdict
dic = defaultdict(int)
N = int(input())
for i in range(1, N):
    X = n_fact(i * (N - i))
    for k, v in X.items():
        if dic[k] < v:
            dic[k] = v
ans = 1
for k, v in dic.items():
    ans *= pow(k, v, MOD)
    ans %= MOD

print(ans)
0