結果

問題 No.1529 Constant Lcm
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-06-04 20:26:56
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 291 ms / 3,000 ms
コード長 1,083 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 97,564 KB
最終ジャッジ日時 2023-08-12 09:26:34
合計ジャッジ時間 5,790 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,432 KB
testcase_01 AC 87 ms
76,260 KB
testcase_02 AC 72 ms
71,452 KB
testcase_03 AC 71 ms
71,028 KB
testcase_04 AC 71 ms
71,364 KB
testcase_05 AC 74 ms
71,316 KB
testcase_06 AC 76 ms
71,244 KB
testcase_07 AC 75 ms
71,352 KB
testcase_08 AC 71 ms
71,404 KB
testcase_09 AC 71 ms
71,364 KB
testcase_10 AC 267 ms
95,020 KB
testcase_11 AC 165 ms
83,156 KB
testcase_12 AC 93 ms
76,840 KB
testcase_13 AC 231 ms
92,384 KB
testcase_14 AC 197 ms
86,400 KB
testcase_15 AC 182 ms
87,304 KB
testcase_16 AC 164 ms
84,728 KB
testcase_17 AC 128 ms
80,676 KB
testcase_18 AC 134 ms
81,088 KB
testcase_19 AC 193 ms
86,824 KB
testcase_20 AC 276 ms
97,164 KB
testcase_21 AC 269 ms
97,564 KB
testcase_22 AC 291 ms
96,644 KB
testcase_23 AC 267 ms
97,448 KB
testcase_24 AC 289 ms
96,836 KB
testcase_25 AC 272 ms
97,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

後半はいらない
素数のmaxをとる
全ての約数素数に関してやる?
logにはなるかな…

"""

import sys
from sys import stdin

N = int(stdin.readline())

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

plis,divlis= Sieve(N+10)

ans = 1
mod = 998244353

#print (plis)

for p in plis:

    nmax = 0
    for i in range(p,N,p):
        rev = (N-i) * i
        now = 0
        while rev % p == 0:
            rev //= p
            now += 1
        nmax = max(now,nmax)

    ans *= pow(p,nmax,mod)
    ans %= mod

print (ans)
0