結果

問題 No.1396 Giri
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-02-14 21:37:33
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,206 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 260,712 KB
最終ジャッジ日時 2023-09-29 14:51:24
合計ジャッジ時間 24,715 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,324 KB
testcase_01 AC 71 ms
71,336 KB
testcase_02 TLE -
testcase_03 AC 73 ms
71,324 KB
testcase_04 AC 70 ms
71,412 KB
testcase_05 TLE -
testcase_06 AC 74 ms
71,320 KB
testcase_07 AC 71 ms
71,208 KB
testcase_08 AC 69 ms
71,360 KB
testcase_09 AC 71 ms
71,116 KB
testcase_10 AC 69 ms
71,376 KB
testcase_11 AC 71 ms
71,552 KB
testcase_12 AC 69 ms
71,332 KB
testcase_13 AC 69 ms
71,200 KB
testcase_14 AC 71 ms
71,328 KB
testcase_15 AC 70 ms
71,124 KB
testcase_16 AC 73 ms
75,328 KB
testcase_17 AC 78 ms
76,524 KB
testcase_18 AC 106 ms
78,056 KB
testcase_19 AC 841 ms
86,688 KB
testcase_20 AC 1,476 ms
96,032 KB
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
権限があれば一括ダウンロードができます

ソースコード

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 *= inverse(nmax,mod)
print (ans % mod)
0