結果

問題 No.1396 Giri
ユーザー 👑 tamatotamato
提出日時 2021-02-14 21:37:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 495 ms / 2,000 ms
コード長 955 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 87,608 KB
実行使用メモリ 93,220 KB
最終ジャッジ日時 2023-09-29 14:51:34
合計ジャッジ時間 6,824 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,852 KB
testcase_01 AC 72 ms
71,828 KB
testcase_02 AC 492 ms
93,100 KB
testcase_03 AC 73 ms
71,752 KB
testcase_04 AC 72 ms
71,612 KB
testcase_05 AC 490 ms
93,060 KB
testcase_06 AC 71 ms
71,692 KB
testcase_07 AC 70 ms
71,828 KB
testcase_08 AC 70 ms
71,700 KB
testcase_09 AC 71 ms
71,848 KB
testcase_10 AC 70 ms
71,544 KB
testcase_11 AC 72 ms
71,640 KB
testcase_12 AC 71 ms
71,548 KB
testcase_13 AC 71 ms
71,672 KB
testcase_14 AC 72 ms
71,712 KB
testcase_15 AC 73 ms
71,384 KB
testcase_16 AC 90 ms
76,916 KB
testcase_17 AC 98 ms
77,748 KB
testcase_18 AC 118 ms
78,708 KB
testcase_19 AC 283 ms
85,772 KB
testcase_20 AC 366 ms
89,204 KB
testcase_21 AC 433 ms
91,556 KB
testcase_22 AC 475 ms
92,868 KB
testcase_23 AC 490 ms
93,220 KB
testcase_24 AC 491 ms
93,032 KB
testcase_25 AC 495 ms
93,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())

    D = list(range(N+1))
    for d in range(2, N+1):
        if D[d] != d:
            continue
        for i in range(2, N+1):
            if d*i > N:
                break
            if D[d*i] == d*i:
                D[d*i] = d

    for i in range(N, -1, -1):
        if D[i] == i:
            p_max = i
            break

    cnt = [0] * (N+1)
    for i in range(1, N+1):
        if i == p_max:
            continue
        ii = i
        cnt_tmp = {}
        while ii > 1:
            d = D[ii]
            if d in cnt_tmp:
                cnt_tmp[d] += 1
            else:
                cnt_tmp[d] = 1
            ii //= d
        for d in cnt_tmp:
            cnt[d] = max(cnt[d], cnt_tmp[d])
    ans = 1
    for i in range(1, N+1):
        ans = (ans * pow(i, cnt[i], mod))%mod
    print(ans)


if __name__ == '__main__':
    main()
0