結果

問題 No.1529 Constant Lcm
ユーザー 👑 KazunKazun
提出日時 2021-04-29 01:58:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,316 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 97,472 KB
最終ジャッジ日時 2024-04-18 16:59:55
合計ジャッジ時間 10,650 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,564 KB
testcase_01 AC 74 ms
73,896 KB
testcase_02 AC 40 ms
55,440 KB
testcase_03 AC 41 ms
54,232 KB
testcase_04 WA -
testcase_05 AC 42 ms
54,372 KB
testcase_06 WA -
testcase_07 AC 40 ms
54,484 KB
testcase_08 WA -
testcase_09 AC 39 ms
54,780 KB
testcase_10 AC 790 ms
96,804 KB
testcase_11 AC 321 ms
83,812 KB
testcase_12 AC 95 ms
77,064 KB
testcase_13 WA -
testcase_14 AC 416 ms
86,796 KB
testcase_15 AC 463 ms
87,916 KB
testcase_16 AC 351 ms
84,588 KB
testcase_17 AC 233 ms
81,172 KB
testcase_18 AC 236 ms
81,228 KB
testcase_19 AC 428 ms
87,076 KB
testcase_20 AC 852 ms
97,096 KB
testcase_21 AC 851 ms
97,380 KB
testcase_22 AC 838 ms
97,368 KB
testcase_23 AC 800 ms
97,472 KB
testcase_24 AC 796 ms
97,096 KB
testcase_25 AC 799 ms
97,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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]=1

    x=4
    while x<=N:
        L[x]=2
        x+=2

    x=9
    while x<=N:
        if L[x]==x:
            L[x]=3
        x+=6

    x=5
    Flag=0
    while x*x<=N:
        if L[x]==x:
            y=x*x
            while y<=N:
                if L[y]==y:
                    L[y]=x
                y+=x<<1
        x+=2+2*Flag
        Flag^=1

    return L

def Faster_Prime_Factorization(N,L):
    """

    L:Smallest_Prime_Factors(N)で求めたリスト
    """
    N=abs(N)

    D=[]
    while N>1:
        a=L[N]
        k=0
        while L[N]==a:
            k+=1
            N//=a
        D.append([a,k])
    return D
#================================================
from collections import defaultdict
N=int(input())
Mod=998244353
D=defaultdict(int)

P=Smallest_Prime_Factor(N)

D=defaultdict(int)

for i in range(1,(N+1)//2):
    A=defaultdict(int)
    for p,e in Faster_Prime_Factorization(i,P):
        A[p]+=e

    for p,e in Faster_Prime_Factorization(N-i,P):
        A[p]+=e

    for p in A:
        D[p]=max(D[p],A[p])

X=1
for p,e in D.items():
    X*=pow(p,e,Mod)
    X%=Mod

print(X)
0