結果

問題 No.1529 Constant Lcm
ユーザー shakayamishakayami
提出日時 2021-06-04 20:15:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 833 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 81,280 KB
最終ジャッジ日時 2024-04-29 23:22:50
合計ジャッジ時間 3,129 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
53,760 KB
testcase_01 AC 52 ms
60,288 KB
testcase_02 AC 45 ms
53,248 KB
testcase_03 AC 46 ms
53,760 KB
testcase_04 AC 46 ms
53,248 KB
testcase_05 AC 46 ms
53,248 KB
testcase_06 WA -
testcase_07 AC 46 ms
53,248 KB
testcase_08 AC 46 ms
53,248 KB
testcase_09 AC 45 ms
53,632 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 84 ms
71,168 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 119 ms
80,768 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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