結果
| 問題 | No.1529 Constant Lcm |
| コンテスト | |
| ユーザー |
kozy
|
| 提出日時 | 2021-06-04 20:20:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,412 ms / 3,000 ms |
| コード長 | 995 bytes |
| コンパイル時間 | 365 ms |
| コンパイル使用メモリ | 82,660 KB |
| 実行使用メモリ | 196,360 KB |
| 最終ジャッジ日時 | 2024-11-19 08:43:55 |
| 合計ジャッジ時間 | 15,619 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in range(n + 1) if is_prime[i]]
N=int(input())
mod=998244353
L=primes(N-1)
R=[0]*N
#コーナーに気をつけて
K=[list() for i in range(N)]
for i in range(len(L)):
s=L[i]
for j in range(s,N,s):
K[j].append(s)
for i in range(1,N):
a=i
b=N-i
if a>b:
break
x=dict()
a2=a
b2=b
for j in range(len(K[a])):
s=K[a][j]
this=0
while a2%s==0:
a2//=s
this+=1
if s in x:
x[s]+=this
else:
x[s]=this
for j in range(len(K[b])):
s=K[b][j]
this=0
while b2%s==0:
b2//=s
this+=1
if s in x:
x[s]+=this
else:
x[s]=this
for i in x:
R[i]=max(R[i],x[i])
ans=1
for i in L:
ans*=pow(i,R[i],mod)
ans%=mod
print(ans)
kozy