結果

問題 No.1396 Giri
ユーザー 👑 KazunKazun
提出日時 2021-02-14 21:33:15
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 446 ms / 2,000 ms
コード長 1,195 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 99,100 KB
最終ジャッジ日時 2023-09-29 14:43:18
合計ジャッジ時間 6,144 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,608 KB
testcase_01 AC 74 ms
71,852 KB
testcase_02 AC 446 ms
98,808 KB
testcase_03 AC 74 ms
71,692 KB
testcase_04 AC 73 ms
71,800 KB
testcase_05 AC 439 ms
98,992 KB
testcase_06 AC 74 ms
71,896 KB
testcase_07 AC 76 ms
71,628 KB
testcase_08 AC 76 ms
71,904 KB
testcase_09 AC 77 ms
71,648 KB
testcase_10 AC 74 ms
71,648 KB
testcase_11 AC 76 ms
71,624 KB
testcase_12 AC 78 ms
71,740 KB
testcase_13 AC 76 ms
71,704 KB
testcase_14 AC 78 ms
71,608 KB
testcase_15 AC 78 ms
71,700 KB
testcase_16 AC 95 ms
78,044 KB
testcase_17 AC 99 ms
78,196 KB
testcase_18 AC 118 ms
79,132 KB
testcase_19 AC 262 ms
88,792 KB
testcase_20 AC 331 ms
93,928 KB
testcase_21 AC 390 ms
96,720 KB
testcase_22 AC 418 ms
98,872 KB
testcase_23 AC 433 ms
99,060 KB
testcase_24 AC 429 ms
99,100 KB
testcase_25 AC 430 ms
98,908 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=True
    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 if Flag else 4

    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())
X=Smallest_Prime_Factor(N)
Mod=998244353

D=defaultdict(int)
for k in range(2,N+1):
    S=Faster_Prime_Factorization(k,X)

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

max_d=max(D.keys())
del D[max_d]

x=1
for p in D:
    x*=pow(p,D[p],Mod)
    x%=Mod

print(x)
0