結果

問題 No.1529 Constant Lcm
ユーザー raven7959raven7959
提出日時 2021-09-27 09:20:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,031 ms / 3,000 ms
コード長 900 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 106,692 KB
最終ジャッジ日時 2023-09-20 08:26:18
合計ジャッジ時間 13,735 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,524 KB
testcase_01 AC 143 ms
77,864 KB
testcase_02 AC 101 ms
71,408 KB
testcase_03 AC 100 ms
71,580 KB
testcase_04 AC 100 ms
71,428 KB
testcase_05 AC 100 ms
71,604 KB
testcase_06 AC 99 ms
71,832 KB
testcase_07 AC 98 ms
71,700 KB
testcase_08 AC 98 ms
71,516 KB
testcase_09 AC 100 ms
71,716 KB
testcase_10 AC 914 ms
104,776 KB
testcase_11 AC 399 ms
87,856 KB
testcase_12 AC 156 ms
78,984 KB
testcase_13 AC 741 ms
100,740 KB
testcase_14 AC 505 ms
92,336 KB
testcase_15 AC 562 ms
93,748 KB
testcase_16 AC 430 ms
89,356 KB
testcase_17 AC 295 ms
84,612 KB
testcase_18 AC 308 ms
84,448 KB
testcase_19 AC 528 ms
92,396 KB
testcase_20 AC 1,031 ms
106,276 KB
testcase_21 AC 987 ms
106,428 KB
testcase_22 AC 984 ms
106,396 KB
testcase_23 AC 927 ms
106,672 KB
testcase_24 AC 931 ms
106,164 KB
testcase_25 AC 935 ms
106,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N=int(input())

isprime=[True]*(N+1) #isprime[i]はiが素数かどうか
isprime[1]=False
minfactor=[-1]*(N+1) #minfactor[i]はiを割り切る最小の素数
minfactor[1]=1
for p in range(2,N+1):
  if isprime[p]:
    minfactor[p]=p
    for q in range(2*p,N+1,p):
      isprime[q]=False
      if minfactor[q]==-1:
        minfactor[q]=p
def factorize(n): #nを素因数分解した時の[素因数,その指数]のリストを返す
  L=[]
  while n>1:
    p=minfactor[n]
    exp=0
    while minfactor[n]==p:
      n//=p
      exp+=1
    L.append([p,exp])
  return L

D=defaultdict(int)
for i in range(1,N//2+1):
  res=defaultdict(int)
  for p,exp in factorize(i):
    res[p]+=exp
  for p,exp in factorize(N-i):
    res[p]+=exp
  for p,exp in res.items():
    D[p]=max(D[p],exp)
ans=1
mod=998244353
for p,exp in D.items():
  ans=ans*pow(p,exp,mod)%mod
print(ans)
0