結果

問題 No.1529 Constant Lcm
ユーザー titiatitia
提出日時 2021-06-04 21:56:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,732 ms / 3,000 ms
コード長 931 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 375,552 KB
最終ジャッジ日時 2024-04-30 02:44:45
合計ジャッジ時間 67,322 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,251 ms
374,912 KB
testcase_01 AC 2,389 ms
374,912 KB
testcase_02 AC 2,207 ms
374,528 KB
testcase_03 AC 2,224 ms
374,912 KB
testcase_04 AC 2,242 ms
374,528 KB
testcase_05 AC 2,282 ms
374,656 KB
testcase_06 AC 2,238 ms
374,656 KB
testcase_07 AC 2,291 ms
374,400 KB
testcase_08 AC 2,287 ms
374,656 KB
testcase_09 AC 2,266 ms
374,656 KB
testcase_10 AC 2,687 ms
375,296 KB
testcase_11 AC 2,500 ms
375,424 KB
testcase_12 AC 2,384 ms
375,296 KB
testcase_13 AC 2,592 ms
374,912 KB
testcase_14 AC 2,517 ms
375,296 KB
testcase_15 AC 2,496 ms
375,296 KB
testcase_16 AC 2,450 ms
375,296 KB
testcase_17 AC 2,425 ms
375,168 KB
testcase_18 AC 2,397 ms
375,424 KB
testcase_19 AC 2,527 ms
375,296 KB
testcase_20 AC 2,634 ms
375,296 KB
testcase_21 AC 2,717 ms
374,912 KB
testcase_22 AC 2,631 ms
375,296 KB
testcase_23 AC 2,732 ms
375,552 KB
testcase_24 AC 2,652 ms
375,424 KB
testcase_25 AC 2,706 ms
375,040 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=[0]*(10**6+1)

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

    for s in D1:
        if s in D1:
            x1=D1[s]
        else:
            x1=0

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

    for s in D2:
        if s in D1:
            x1=D1[s]
        else:
            x1=0

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

ANS=1
for i in range(10**6+1):
    if LCM[i]==0:
        continue
    ANS=ANS*pow(i,LCM[i],mod)%mod

print(ANS)
0