結果

問題 No.1396 Giri
ユーザー 👑 terry_u16terry_u16
提出日時 2021-02-14 21:47:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 633 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 101,612 KB
最終ジャッジ日時 2023-09-29 15:07:24
合計ジャッジ時間 7,856 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,432 KB
testcase_01 AC 70 ms
71,348 KB
testcase_02 AC 601 ms
101,440 KB
testcase_03 AC 70 ms
71,488 KB
testcase_04 AC 69 ms
71,292 KB
testcase_05 AC 603 ms
101,612 KB
testcase_06 AC 71 ms
71,564 KB
testcase_07 AC 71 ms
71,528 KB
testcase_08 AC 72 ms
71,440 KB
testcase_09 AC 71 ms
71,608 KB
testcase_10 AC 70 ms
71,404 KB
testcase_11 AC 71 ms
71,640 KB
testcase_12 AC 73 ms
71,144 KB
testcase_13 AC 73 ms
71,564 KB
testcase_14 AC 71 ms
71,292 KB
testcase_15 AC 73 ms
71,144 KB
testcase_16 AC 90 ms
76,580 KB
testcase_17 AC 102 ms
77,512 KB
testcase_18 AC 130 ms
78,524 KB
testcase_19 AC 350 ms
88,620 KB
testcase_20 AC 454 ms
94,664 KB
testcase_21 AC 571 ms
98,568 KB
testcase_22 AC 616 ms
101,048 KB
testcase_23 AC 633 ms
101,576 KB
testcase_24 AC 630 ms
101,312 KB
testcase_25 AC 616 ms
101,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
n = int(input())

erathosthenes = [1] * (n + 1)

for i in range(2, len(erathosthenes)):
    if erathosthenes[i] == 1:
        for j in range(i, len(erathosthenes), i):
            if erathosthenes[j] == 1:
                erathosthenes[j] = i

for i in reversed(range(1, len(erathosthenes))):
    if erathosthenes[i] == i:
        max_prime = i
        break

factors = {}

for i in range(1, len(erathosthenes)):
    if i != max_prime:
        current = i
        primes = {}
        while erathosthenes[current] > 1:
            p = erathosthenes[current]
            count = primes.get(p, 0)
            primes[p] = count + 1
            current //= p

        for p, count in primes.items():
            c = factors.get(p, 0)
            factors[p] = max(c, count)

result = 1

for p, count in factors.items():
    for _ in range(count):
        result *= p
        result %= mod
        
print(result)
0