結果
問題 | No.1529 Constant Lcm |
ユーザー |
![]() |
提出日時 | 2023-02-01 12:56:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 169 ms / 3,000 ms |
コード長 | 746 bytes |
コンパイル時間 | 394 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 99,808 KB |
最終ジャッジ日時 | 2024-07-01 09:13:16 |
合計ジャッジ時間 | 4,298 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 |
ソースコード
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)