結果

問題 No.1396 Giri
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-02-14 21:38:02
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 1,220 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 96,784 KB
最終ジャッジ日時 2023-09-29 14:51:38
合計ジャッジ時間 3,710 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,180 KB
testcase_01 AC 67 ms
71,184 KB
testcase_02 AC 121 ms
96,640 KB
testcase_03 AC 69 ms
71,280 KB
testcase_04 AC 70 ms
71,244 KB
testcase_05 AC 120 ms
96,668 KB
testcase_06 AC 69 ms
71,220 KB
testcase_07 AC 69 ms
71,272 KB
testcase_08 AC 67 ms
71,400 KB
testcase_09 AC 68 ms
71,084 KB
testcase_10 AC 69 ms
71,216 KB
testcase_11 AC 70 ms
71,220 KB
testcase_12 AC 68 ms
71,532 KB
testcase_13 AC 68 ms
71,232 KB
testcase_14 AC 68 ms
71,316 KB
testcase_15 AC 69 ms
71,028 KB
testcase_16 AC 72 ms
75,192 KB
testcase_17 AC 76 ms
76,508 KB
testcase_18 AC 81 ms
77,660 KB
testcase_19 AC 100 ms
86,560 KB
testcase_20 AC 109 ms
91,108 KB
testcase_21 AC 116 ms
94,592 KB
testcase_22 AC 120 ms
96,508 KB
testcase_23 AC 121 ms
96,784 KB
testcase_24 AC 120 ms
96,708 KB
testcase_25 AC 121 ms
96,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

すべての倍数
ある数字を除いた全体のlcmがわかればおk

算数
一番大きい素数…?

全部のlcmを取った時、
素数のN乗を考えたとき、1回しか出てこないやつの内最大

"""

import math
import sys
from sys import stdin
mod = 998244353
def inverse(a,mod): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)

def Sieve(n): #n以下の素数全列挙(O(nloglogn)) retは素数が入ってる。divlisはその数字の素因数が一つ入ってる

    ret = []
    divlis = [-1] * (n+1) #何で割ったかのリスト(初期値は-1)
    
    flag = [True] * (n+1)
    flag[0] = False
    flag[1] = False

    ind = 2
    while ind <= n:

        if flag[ind]:
            ret.append(ind)

            ind2 = ind ** 2

            while ind2 <= n:
                flag[ind2] = False
                divlis[ind2] = ind
                ind2 += ind

        ind += 1

    return ret,divlis

N = int(stdin.readline())

prime,tmp = Sieve(N)

nmax = 1
ans = 1

for p in prime:

    pm = p
    while pm * p <= N:
        pm *= p

    if N // pm == 1:
        nmax = max(nmax,p)
    ans *= pm
    ans %= mod

ans *= inverse(nmax,mod)
print (ans % mod)
0