結果

問題 No.1529 Constant Lcm
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-10 13:28:54
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 866 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 667,756 KB
最終ジャッジ日時 2024-04-26 20:05:09
合計ジャッジ時間 33,959 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
68,736 KB
testcase_01 AC 126 ms
85,888 KB
testcase_02 AC 80 ms
68,480 KB
testcase_03 AC 81 ms
68,352 KB
testcase_04 AC 80 ms
68,352 KB
testcase_05 AC 80 ms
68,608 KB
testcase_06 AC 80 ms
68,864 KB
testcase_07 AC 80 ms
68,608 KB
testcase_08 AC 80 ms
68,608 KB
testcase_09 AC 81 ms
68,608 KB
testcase_10 MLE -
testcase_11 AC 1,015 ms
295,004 KB
testcase_12 AC 154 ms
95,488 KB
testcase_13 MLE -
testcase_14 AC 1,437 ms
379,648 KB
testcase_15 AC 1,495 ms
397,568 KB
testcase_16 AC 1,116 ms
326,656 KB
testcase_17 AC 606 ms
216,064 KB
testcase_18 AC 595 ms
226,304 KB
testcase_19 AC 1,483 ms
388,224 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

N = 10**6+1
spf = [-1]*(N+1)
for i in range(N+1):
    spf[i] = i
for i in range(2, int(math.sqrt(N))+1):
    if spf[i] == i:
        for j in range(i*2, N+1, i):
            if spf[j] == j:
                spf[j] = i

def factorize(n):
    d = {}
    while n != 1:
        p = spf[n]
        if p in d:
            d[p] += 1
        else:
            d[p] = 1
        n //= p
    return d

n = int(input())

mod = 998244353
from collections import defaultdict
D = [defaultdict(lambda: 0) for i in range(n)]
for i in range(1, n):
    if i == 1:
        continue
    d = factorize(i)
    for k, v in d.items():
        D[i][k] += v
        D[n-i][k] += v
P = defaultdict(lambda: 0)
for i in range(1, n):
    d = D[i]
    for k, v in d.items():
        P[k] = max(P[k], v)
ans = 1
for k, v in P.items():
    ans *= pow(k, v, mod)
    ans %= mod
print(ans)
0