結果

問題 No.1529 Constant Lcm
ユーザー titiatitia
提出日時 2021-06-04 21:42:24
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 773 bytes
コンパイル時間 1,175 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 380,112 KB
最終ジャッジ日時 2023-08-12 12:18:32
合計ジャッジ時間 69,914 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,129 ms
364,820 KB
testcase_01 AC 2,104 ms
368,260 KB
testcase_02 AC 1,924 ms
364,492 KB
testcase_03 AC 2,248 ms
364,648 KB
testcase_04 AC 2,016 ms
364,652 KB
testcase_05 AC 1,935 ms
364,820 KB
testcase_06 AC 1,869 ms
365,004 KB
testcase_07 AC 1,886 ms
365,044 KB
testcase_08 AC 2,298 ms
364,700 KB
testcase_09 AC 1,897 ms
364,684 KB
testcase_10 TLE -
testcase_11 AC 2,432 ms
371,808 KB
testcase_12 AC 2,103 ms
368,560 KB
testcase_13 AC 2,815 ms
377,592 KB
testcase_14 AC 2,898 ms
373,576 KB
testcase_15 AC 2,620 ms
374,636 KB
testcase_16 AC 2,480 ms
372,472 KB
testcase_17 AC 2,393 ms
370,776 KB
testcase_18 AC 2,349 ms
370,512 KB
testcase_19 AC 2,558 ms
373,444 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 AC 2,923 ms
379,524 KB
testcase_23 AC 2,936 ms
379,736 KB
testcase_24 TLE -
testcase_25 AC 2,981 ms
380,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())

mod=998244353

X=[i for i in range(10**6+1)]
FACT=[dict() for i in range(10**6+1)]

for i in range(2,10**6+1):
    if X[i]!=1:
        k=X[i]
        for j in range(i,10**6+1,i):
            X[j]//=k
            if k in FACT[j]:
                FACT[j][k]+=1
            else:
                FACT[j][k]=1

LCM=dict()

for j in range(1,N//2+1):
    D1=FACT[j]
    D2=FACT[N-j]

    for s in set(D1.keys())|set(D2.keys()):
        if s in D1:
            x1=D1[s]
        else:
            x1=0

        if s in D2:
            x2=D2[s]
        else:
            x2=0
            
        if s in LCM:
            LCM[s]=max(LCM[s],x1+x2)
        else:
            LCM[s]=x1+x2

#print(LCM)

ANS=1
for s in LCM:
    ANS=ANS*pow(s,LCM[s],mod)%mod

print(ANS)
0