結果

問題 No.1529 Constant Lcm
ユーザー kamomekamome
提出日時 2021-06-04 21:25:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,086 ms / 3,000 ms
コード長 580 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 86,604 KB
実行使用メモリ 95,276 KB
最終ジャッジ日時 2023-08-12 11:36:47
合計ジャッジ時間 14,051 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,252 KB
testcase_01 AC 154 ms
77,972 KB
testcase_02 AC 81 ms
71,340 KB
testcase_03 AC 82 ms
70,996 KB
testcase_04 AC 78 ms
71,496 KB
testcase_05 AC 78 ms
71,332 KB
testcase_06 AC 80 ms
71,388 KB
testcase_07 AC 83 ms
71,448 KB
testcase_08 AC 80 ms
71,536 KB
testcase_09 AC 80 ms
71,412 KB
testcase_10 AC 938 ms
92,668 KB
testcase_11 AC 415 ms
84,428 KB
testcase_12 AC 133 ms
78,468 KB
testcase_13 AC 802 ms
91,800 KB
testcase_14 AC 541 ms
86,648 KB
testcase_15 AC 584 ms
86,628 KB
testcase_16 AC 480 ms
84,784 KB
testcase_17 AC 319 ms
83,172 KB
testcase_18 AC 355 ms
83,084 KB
testcase_19 AC 552 ms
86,940 KB
testcase_20 AC 1,020 ms
94,272 KB
testcase_21 AC 1,042 ms
94,564 KB
testcase_22 AC 1,044 ms
94,640 KB
testcase_23 AC 1,086 ms
94,432 KB
testcase_24 AC 1,074 ms
94,256 KB
testcase_25 AC 1,030 ms
95,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
N = int(input())
MOD = 998244353
spf = [1]*(N+1)
for i in range(2, N+1):
    for j in range(i, N+1, i):
        if spf[j] == 1:
            spf[j] = i


def factorization(n):
    x = []
    while n > 1:
        x.append(spf[n])
        n //= spf[n]
    return x


A = [0]*(N+1)
ans = 1
for i in range(1, N//2+1):
    a = i
    b = N-i
    x = Counter(factorization(a)+factorization(b)).most_common()
    for n, c in x:
        A[n] = max(A[n], c)

for i in range(N+1):
    ans = ans*pow(i, A[i], MOD) % MOD
print(ans)
0