結果

問題 No.1529 Constant Lcm
ユーザー hirakuhiraku
提出日時 2021-06-05 08:56:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 666 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 130,944 KB
最終ジャッジ日時 2024-05-01 03:41:10
合計ジャッジ時間 5,353 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
17,948 KB
testcase_01 AC 52 ms
11,264 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 32 ms
10,880 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter


# 素因数分解(Counter)
def prime_factorize(n):
    a = Counter()
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a


n = int(input())

MOD = 998244353

# 始めに、1~nまでの素因数分解を前計算
ps = [0] * (n + 1)
for i in range(1, n + 1):
    ps[i] = prime_factorize(i)

l = Counter()
for i in range(1, n // 2 + 1):
    l |= (ps[i] + ps[n - i])

ans = 1
for k, v in l.items():
    ans *= pow(k, v, MOD)
    ans %= MOD

print(ans)
0