結果

問題 No.1396 Giri
ユーザー shotoyooshotoyoo
提出日時 2021-02-14 21:40:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 957 ms / 2,000 ms
コード長 953 bytes
コンパイル時間 1,004 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 116,408 KB
最終ジャッジ日時 2023-09-29 14:56:07
合計ジャッジ時間 11,112 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,636 KB
testcase_01 AC 92 ms
71,744 KB
testcase_02 AC 957 ms
116,256 KB
testcase_03 AC 98 ms
71,716 KB
testcase_04 AC 94 ms
71,784 KB
testcase_05 AC 940 ms
116,344 KB
testcase_06 AC 93 ms
71,744 KB
testcase_07 AC 94 ms
71,496 KB
testcase_08 AC 94 ms
71,900 KB
testcase_09 AC 94 ms
71,464 KB
testcase_10 AC 93 ms
71,616 KB
testcase_11 AC 93 ms
71,828 KB
testcase_12 AC 95 ms
71,784 KB
testcase_13 AC 93 ms
71,572 KB
testcase_14 AC 94 ms
71,780 KB
testcase_15 AC 97 ms
71,844 KB
testcase_16 AC 123 ms
78,176 KB
testcase_17 AC 139 ms
78,552 KB
testcase_18 AC 179 ms
80,532 KB
testcase_19 AC 534 ms
98,092 KB
testcase_20 AC 712 ms
106,728 KB
testcase_21 AC 858 ms
112,468 KB
testcase_22 AC 923 ms
116,236 KB
testcase_23 AC 918 ms
116,408 KB
testcase_24 AC 950 ms
116,384 KB
testcase_25 AC 948 ms
116,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")

n = int(input())
def hurui(n):
    pl = []
    mpf = [None]*(n+1)
    for d in range(2,n):
        if mpf[d] is None:
            mpf[d] = d
            pl.append(d)
        for p in pl:
            if p*d>n or p>mpf[d]:
                break
            mpf[p*d] = p
    return pl, mpf
from collections import defaultdict
def factor(num):
    d = defaultdict(int)
    if num==1:
        d.update({1:1})
        return d
    while num>1:
        d[mpf[num]] += 1
        num //= mpf[num]
    return d
ps,mpf = hurui(n+10)
for i in range(n, 1, -1):
    if mpf[i]==i:
        break
ans = 1
M = 998244353
d = defaultdict(int)
for j in range(1, n+1):
    if i==j:
        continue
    f = factor(j)
    for k,v in f.items():
        d[k] = max(d[k], v)
for k,v in d.items():
    ans *= pow(k,v,M)
    ans %= M
print(ans)
0