結果
問題 | No.1396 Giri |
ユーザー |
👑 ![]() |
提出日時 | 2021-02-14 21:33:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 505 ms / 2,000 ms |
コード長 | 1,195 bytes |
コンパイル時間 | 147 ms |
コンパイル使用メモリ | 82,440 KB |
実行使用メモリ | 97,536 KB |
最終ジャッジ日時 | 2024-07-22 08:54:15 |
合計ジャッジ時間 | 5,800 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
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]=1x=4while x<=N:L[x]=2x+=2x=9while x<=N:if L[x]==x:L[x]=3x+=6x=5Flag=Truewhile x*x<=N:if L[x]==x:y=x*xwhile y<=N:if L[y]==y:L[y]=xy+=x<<1x+=2 if Flag else 4return Ldef Faster_Prime_Factorization(N,L):"""L:Smallest_Prime_Factors(N)で求めたリスト"""N=abs(N)D=[]while N>1:a=L[N]k=0while L[N]==a:k+=1N//=aD.append([a,k])return D#================================================from collections import defaultdictN=int(input())X=Smallest_Prime_Factor(N)Mod=998244353D=defaultdict(int)for k in range(2,N+1):S=Faster_Prime_Factorization(k,X)for p,e in S:D[p]=max(D[p],e)max_d=max(D.keys())del D[max_d]x=1for p in D:x*=pow(p,D[p],Mod)x%=Modprint(x)