結果

問題 No.1529 Constant Lcm
ユーザー lemondolemondo
提出日時 2021-06-04 20:31:54
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 928 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 456,784 KB
最終ジャッジ日時 2024-04-29 23:59:35
合計ジャッジ時間 23,294 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,016 KB
testcase_01 AC 127 ms
78,080 KB
testcase_02 AC 41 ms
53,888 KB
testcase_03 AC 40 ms
53,632 KB
testcase_04 AC 40 ms
53,632 KB
testcase_05 AC 38 ms
53,760 KB
testcase_06 AC 40 ms
53,504 KB
testcase_07 AC 40 ms
53,632 KB
testcase_08 AC 41 ms
53,888 KB
testcase_09 AC 42 ms
53,632 KB
testcase_10 TLE -
testcase_11 AC 1,220 ms
224,000 KB
testcase_12 AC 169 ms
84,540 KB
testcase_13 AC 2,742 ms
371,540 KB
testcase_14 AC 1,674 ms
283,264 KB
testcase_15 AC 1,763 ms
285,184 KB
testcase_16 AC 1,267 ms
245,760 KB
testcase_17 AC 690 ms
168,320 KB
testcase_18 AC 741 ms
176,332 KB
testcase_19 AC 1,682 ms
285,184 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)

N = int(input())
mod = 998244353

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

from collections import Counter, defaultdict
count = []
for i in range(1, N):
    count.append(Counter(prime_factorize(i)))
primes = defaultdict(int)
for i in range(N-1):
    for key in count[i].keys():
        primes[key] = max(count[i][key]+count[-i-1][key], primes[key])
    for key in count[-i-1].keys():
        primes[key] = max(count[i][key]+count[-i-1][key], primes[key])
ans = 1
for key in primes.keys():
    ans *= pow(key, primes[key], mod)
    ans %= mod
print(ans)
0