結果
| 問題 | 
                            No.1529 Constant Lcm
                             | 
                    
| コンテスト | |
| ユーザー | 
                            👑  Kazun
                         | 
                    
| 提出日時 | 2021-04-29 00:48:27 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,582 ms / 3,000 ms | 
| コード長 | 1,304 bytes | 
| コンパイル時間 | 287 ms | 
| コンパイル使用メモリ | 82,460 KB | 
| 実行使用メモリ | 97,812 KB | 
| 最終ジャッジ日時 | 2024-10-10 10:17:45 | 
| 合計ジャッジ時間 | 17,166 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 24 | 
ソースコード
def Smallest_Prime_Factor(N):
    """0,1,2,...,Nの最小の素因数のリスト(0,1については1にしている)
    """
    if N==0:
        return [1]
    N=abs(N)
    L=list(range(N+1))
    L[0]=L[1]=1
    x=4
    while x<=N:
        L[x]=2
        x+=2
    x=9
    while x<=N:
        if L[x]==x:
            L[x]=3
        x+=6
    x=5
    Flag=True
    while x*x<=N:
        if L[x]==x:
            y=x*x
            while y<=N:
                if L[y]==y:
                    L[y]=x
                y+=x<<1
        x+=2 if Flag else 4
    return L
def Faster_Prime_Factorization(N,L):
    """
    L:Smallest_Prime_Factors(N)で求めたリスト
    """
    N=abs(N)
    D=[]
    while N>1:
        a=L[N]
        k=0
        while L[N]==a:
            k+=1
            N//=a
        D.append([a,k])
    return D
#================================================
from collections import defaultdict
N=int(input())
Mod=998244353
D=defaultdict(int)
P=Smallest_Prime_Factor(N)
D=defaultdict(int)
for i in range(1,N):
    A=defaultdict(int)
    for p,e in Faster_Prime_Factorization(i,P):
        A[p]+=e
    for p,e in Faster_Prime_Factorization(N-i,P):
        A[p]+=e
    for p in A:
        D[p]=max(D[p],A[p])
X=1
for p,e in D.items():
    X*=pow(p,e,Mod)
    X%=Mod
print(X)
            
            
            
        
            
Kazun