結果

問題 No.1396 Giri
ユーザー H3PO4H3PO4
提出日時 2021-02-14 21:59:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 19,664 KB
最終ジャッジ日時 2023-09-29 15:28:31
合計ジャッジ時間 2,779 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,956 KB
testcase_01 AC 14 ms
8,012 KB
testcase_02 AC 188 ms
19,520 KB
testcase_03 AC 15 ms
7,940 KB
testcase_04 AC 13 ms
8,016 KB
testcase_05 AC 186 ms
19,588 KB
testcase_06 AC 14 ms
7,936 KB
testcase_07 AC 14 ms
8,052 KB
testcase_08 AC 14 ms
7,992 KB
testcase_09 AC 14 ms
7,964 KB
testcase_10 AC 13 ms
7,952 KB
testcase_11 AC 13 ms
7,976 KB
testcase_12 AC 14 ms
7,972 KB
testcase_13 AC 13 ms
7,968 KB
testcase_14 AC 15 ms
7,936 KB
testcase_15 AC 14 ms
7,992 KB
testcase_16 AC 13 ms
8,012 KB
testcase_17 AC 14 ms
8,648 KB
testcase_18 AC 26 ms
9,272 KB
testcase_19 AC 104 ms
14,168 KB
testcase_20 AC 130 ms
16,372 KB
testcase_21 AC 162 ms
18,212 KB
testcase_22 AC 174 ms
19,272 KB
testcase_23 AC 182 ms
19,568 KB
testcase_24 AC 177 ms
19,664 KB
testcase_25 AC 174 ms
19,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

MOD = 998244353
lcm = lambda a, b: a * b // gcd(a, b)
modinv = lambda a, mod=MOD: pow(a, mod - 2, mod)


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return (i for i in range(n + 1) if is_prime[i])


N = int(input())

P = tuple(primes(N))
L = 1
for p in P:
    tmp = N
    ct = 0
    while tmp >= p:
        tmp //= p
        ct += 1
    L *= pow(p, ct, MOD)
    L %= MOD
print(L * modinv(max(P)) % MOD)
0