結果

問題 No.1529 Constant Lcm
ユーザー Eki1009Eki1009
提出日時 2021-06-04 20:17:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 614 ms / 3,000 ms
コード長 678 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 94,652 KB
最終ジャッジ日時 2023-08-12 09:05:11
合計ジャッジ時間 10,487 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,632 KB
testcase_01 AC 130 ms
78,072 KB
testcase_02 AC 92 ms
71,800 KB
testcase_03 AC 92 ms
71,832 KB
testcase_04 AC 92 ms
71,628 KB
testcase_05 AC 93 ms
71,612 KB
testcase_06 AC 94 ms
71,412 KB
testcase_07 AC 92 ms
71,384 KB
testcase_08 AC 92 ms
71,928 KB
testcase_09 AC 93 ms
71,860 KB
testcase_10 AC 558 ms
92,700 KB
testcase_11 AC 296 ms
84,136 KB
testcase_12 AC 141 ms
79,176 KB
testcase_13 AC 510 ms
90,628 KB
testcase_14 AC 355 ms
86,484 KB
testcase_15 AC 366 ms
86,744 KB
testcase_16 AC 306 ms
84,848 KB
testcase_17 AC 228 ms
81,808 KB
testcase_18 AC 242 ms
82,672 KB
testcase_19 AC 371 ms
86,348 KB
testcase_20 AC 596 ms
94,044 KB
testcase_21 AC 605 ms
94,052 KB
testcase_22 AC 614 ms
94,652 KB
testcase_23 AC 598 ms
93,844 KB
testcase_24 AC 586 ms
94,172 KB
testcase_25 AC 594 ms
94,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
mod = 998244353
n = int(input())
P = [0]*(n+1)
P[0] = P[1] = 1
for i in range(2, n+1):
    if P[i]:
        continue
    for j in range(i, n+1, i):
        P[j] = i
C = [0]*(n+1)
for i in range(1, n//2+1):
    j = n-i
    D = defaultdict(int)
    while i > 1:
        d = 0
        p = P[i]
        while i%p == 0:
            i //= p
            d += 1
        D[p] += d
    while j > 1:
        d = 0
        p = P[j]
        while j%p == 0:
            j //= p
            d += 1
        D[p] += d
    for k, v in D.items():
        C[k] = max(C[k], v)
ans = 1
for i in range(1, n+1):
    ans *= pow(i, C[i], mod)
    ans %= mod
print(ans)
0