結果

問題 No.1529 Constant Lcm
ユーザー rlangevinrlangevin
提出日時 2023-02-01 12:56:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 190 ms / 3,000 ms
コード長 746 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 103,856 KB
最終ジャッジ日時 2023-09-14 01:11:14
合計ジャッジ時間 5,755 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,496 KB
testcase_01 AC 82 ms
75,996 KB
testcase_02 AC 71 ms
71,320 KB
testcase_03 AC 73 ms
71,100 KB
testcase_04 AC 72 ms
71,240 KB
testcase_05 AC 74 ms
71,452 KB
testcase_06 AC 71 ms
70,940 KB
testcase_07 AC 72 ms
71,076 KB
testcase_08 AC 73 ms
71,436 KB
testcase_09 AC 72 ms
71,100 KB
testcase_10 AC 175 ms
102,228 KB
testcase_11 AC 120 ms
85,460 KB
testcase_12 AC 88 ms
76,968 KB
testcase_13 AC 157 ms
97,832 KB
testcase_14 AC 134 ms
89,792 KB
testcase_15 AC 138 ms
91,216 KB
testcase_16 AC 127 ms
87,032 KB
testcase_17 AC 109 ms
82,172 KB
testcase_18 AC 110 ms
82,372 KB
testcase_19 AC 134 ms
90,016 KB
testcase_20 AC 189 ms
103,776 KB
testcase_21 AC 190 ms
103,460 KB
testcase_22 AC 184 ms
103,856 KB
testcase_23 AC 186 ms
103,772 KB
testcase_24 AC 185 ms
103,840 KB
testcase_25 AC 182 ms
103,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt, ceil


def Sieve(n):
    lst = [True] * (n + 1)
    S = set()
    for i in range(2, ceil(sqrt(n)) + 1):
        if lst[i]:
            for j in range(2 * i, n + 1, i):
                lst[j] = False
    for i in range(2, n + 1):
        if lst[i]:
            S.add(i)
    return S

N = int(input())
mod = 998244353
L = [0] * N
ans = 1
for now in Sieve(N - 1):
    p = now
    
    cnt = 0
    maxv = 0
    while p <= N - 1:
        if p > N - 1:
            break
        cnt += 1
        
        for i in range(p, N, p):
            L[i] = cnt
            maxv = max(maxv, L[i] + L[N - i])
        p *= now
    

    ans *= pow(now, maxv, mod)
    ans %= mod
    for i in range(now, N, now):
        L[i] = 0

print(ans)
0