結果

問題 No.1529 Constant Lcm
ユーザー shakayamishakayami
提出日時 2021-06-04 20:15:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 833 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 82,624 KB
実行使用メモリ 81,296 KB
最終ジャッジ日時 2024-11-19 08:21:20
合計ジャッジ時間 3,055 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
mod=998244353
N=int(input())
isPrime=[True for i in range(N+1)]
isPrime[0]=False;isPrime[1]=False
Prime=[]
for i in range(2,N+1):
    if isPrime[i]:
        for j in range(2*i,N+1,i):
            isPrime[j]=False
        Prime.append(i)
def primefact(M):
    res=defaultdict(int)
    p=2
    while(p*p<=M):
        while(M%p==0):
            res[p]+=1
            M//=p
        p+=1
    if M>1:res[M]+=1
    return res
PF=primefact(N)
ans=1
for p in Prime:
    if N%p==0:
        continue
    k=0
    while(p**(k+1)<N):k+=1
    ans*=pow(p,k,mod)
    ans%=mod
for p in PF:
    A=N//(p**PF[p])
    if A>1:
        cnt=PF[p]*2
        if A>p:
            cnt+=1
        ans*=pow(p,cnt,mod)
        ans%=mod
    else:
        cnt=(PF[p]-1)*2
        ans*=pow(p,cnt,mod)
        ans%=mod
print(ans)



0