結果

問題 No.1396 Giri
ユーザー H3PO4H3PO4
提出日時 2021-02-14 22:03:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 805 ms
コンパイル使用メモリ 10,668 KB
実行使用メモリ 19,604 KB
最終ジャッジ日時 2023-09-29 15:34:41
合計ジャッジ時間 3,510 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,960 KB
testcase_01 AC 13 ms
7,804 KB
testcase_02 AC 188 ms
19,476 KB
testcase_03 AC 14 ms
7,776 KB
testcase_04 AC 14 ms
7,768 KB
testcase_05 AC 182 ms
19,444 KB
testcase_06 AC 14 ms
7,736 KB
testcase_07 AC 13 ms
7,924 KB
testcase_08 AC 13 ms
7,812 KB
testcase_09 AC 13 ms
7,880 KB
testcase_10 AC 13 ms
7,808 KB
testcase_11 AC 13 ms
7,872 KB
testcase_12 AC 13 ms
7,828 KB
testcase_13 AC 12 ms
7,812 KB
testcase_14 AC 12 ms
7,932 KB
testcase_15 AC 13 ms
7,760 KB
testcase_16 AC 13 ms
7,828 KB
testcase_17 AC 14 ms
8,492 KB
testcase_18 AC 26 ms
9,168 KB
testcase_19 AC 96 ms
14,152 KB
testcase_20 AC 126 ms
16,392 KB
testcase_21 AC 160 ms
18,156 KB
testcase_22 AC 176 ms
19,256 KB
testcase_23 AC 182 ms
19,604 KB
testcase_24 AC 181 ms
19,408 KB
testcase_25 AC 178 ms
19,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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])


MOD = 998244353
modinv = lambda a, mod=MOD: pow(a, mod - 2, mod)

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