結果

問題 No.1529 Constant Lcm
ユーザー 👑 H20H20
提出日時 2021-06-04 21:38:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,301 ms / 3,000 ms
コード長 698 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 86,608 KB
実行使用メモリ 260,228 KB
最終ジャッジ日時 2023-08-12 12:10:36
合計ジャッジ時間 24,997 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,748 KB
testcase_01 AC 146 ms
77,864 KB
testcase_02 AC 80 ms
71,504 KB
testcase_03 AC 76 ms
71,176 KB
testcase_04 AC 81 ms
71,328 KB
testcase_05 AC 77 ms
71,428 KB
testcase_06 AC 75 ms
71,584 KB
testcase_07 AC 83 ms
71,392 KB
testcase_08 AC 79 ms
71,544 KB
testcase_09 AC 79 ms
71,632 KB
testcase_10 AC 2,017 ms
242,068 KB
testcase_11 AC 725 ms
136,072 KB
testcase_12 AC 131 ms
80,320 KB
testcase_13 AC 1,650 ms
218,984 KB
testcase_14 AC 994 ms
164,456 KB
testcase_15 AC 1,080 ms
168,300 KB
testcase_16 AC 820 ms
144,680 KB
testcase_17 AC 461 ms
111,028 KB
testcase_18 AC 515 ms
114,928 KB
testcase_19 AC 1,072 ms
164,632 KB
testcase_20 AC 2,301 ms
260,228 KB
testcase_21 AC 2,244 ms
260,132 KB
testcase_22 AC 2,194 ms
260,080 KB
testcase_23 AC 2,217 ms
260,132 KB
testcase_24 AC 2,114 ms
260,144 KB
testcase_25 AC 2,155 ms
260,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import collections
#素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N=int(input())
L = []
L.append([])
for i in range(1,N):
    L.append(prime_factorize(i))

d = collections.defaultdict(int)

for i in range(1,N//2+1):
    TEMP = L[i]+L[N-i]
    dd = collections.defaultdict(int)
    for temp in TEMP:
        dd[temp]+=1
    for k,v in dd.items():
        d[k]=max(d[k],v)

ans = 1
for k,v in d.items():
    ans = ans*k**v%998244353
print(ans)
0