結果

問題 No.1396 Giri
ユーザー tanon710tanon710
提出日時 2021-02-14 22:40:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 627 ms / 2,000 ms
コード長 693 bytes
コンパイル時間 1,592 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 98,020 KB
最終ジャッジ日時 2023-09-29 16:25:06
合計ジャッジ時間 9,020 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
84,796 KB
testcase_01 AC 118 ms
84,720 KB
testcase_02 AC 627 ms
97,840 KB
testcase_03 AC 120 ms
84,792 KB
testcase_04 AC 117 ms
84,816 KB
testcase_05 AC 565 ms
97,900 KB
testcase_06 AC 117 ms
84,640 KB
testcase_07 AC 116 ms
84,736 KB
testcase_08 AC 117 ms
84,744 KB
testcase_09 AC 117 ms
84,840 KB
testcase_10 AC 115 ms
84,840 KB
testcase_11 AC 116 ms
84,836 KB
testcase_12 AC 117 ms
84,728 KB
testcase_13 AC 119 ms
84,832 KB
testcase_14 AC 119 ms
84,840 KB
testcase_15 AC 118 ms
84,732 KB
testcase_16 AC 135 ms
86,056 KB
testcase_17 AC 144 ms
85,908 KB
testcase_18 AC 169 ms
86,480 KB
testcase_19 AC 355 ms
91,292 KB
testcase_20 AC 450 ms
95,452 KB
testcase_21 AC 523 ms
96,448 KB
testcase_22 AC 568 ms
97,976 KB
testcase_23 AC 574 ms
98,020 KB
testcase_24 AC 600 ms
97,856 KB
testcase_25 AC 583 ms
97,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

MAXN = 10**6+10
sieve = [i for i in range(MAXN+1)]
p = 2
while p*p <= MAXN:
    if sieve[p] == p:
        for q in range(2*p,MAXN+1,p):
            if sieve[q] == q:
                sieve[q] = p
    p += 1

mod=998244353

n=int(input())
maxprime=-1
for i in range(n,1,-1):
    if sieve[i]==i:
        maxprime=i
        break
dic=collections.defaultdict(int)
for i in range(2,n+1):
    if i==maxprime:
        continue
    tmp=collections.defaultdict(int)
    while i!=1:
        p=sieve[i]
        tmp[p]+=1
        i//=p
    for key in tmp.keys():
        dic[key]=max(dic[key],tmp[key])
ans=1
for key in dic.keys():
    ans*=pow(key,dic[key],mod)
    ans%=mod
print(ans)
0