結果
| 問題 | No.1529 Constant Lcm |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-04 20:34:29 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 851 bytes |
| 記録 | |
| コンパイル時間 | 464 ms |
| コンパイル使用メモリ | 85,268 KB |
| 実行使用メモリ | 148,096 KB |
| 最終ジャッジ日時 | 2026-05-13 17:18:11 |
| 合計ジャッジ時間 | 5,452 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 TLE * 1 -- * 15 |
ソースコード
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(1, N):
count = Counter(prime_factorize(i*(N-i)))
for key in count.keys():
primes[key] = max(count[key], primes[key])
ans = 1
for key in primes.keys():
ans *= pow(key, primes[key], mod)
ans %= mod
print(ans)