結果

問題 No.1529 Constant Lcm
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-06-04 20:34:15
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 942 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 459,072 KB
最終ジャッジ日時 2024-04-30 00:04:48
合計ジャッジ時間 14,304 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 241 ms
93,696 KB
testcase_01 AC 281 ms
90,240 KB
testcase_02 AC 229 ms
88,832 KB
testcase_03 AC 226 ms
88,576 KB
testcase_04 AC 232 ms
88,448 KB
testcase_05 AC 226 ms
88,576 KB
testcase_06 AC 228 ms
88,192 KB
testcase_07 AC 229 ms
88,576 KB
testcase_08 AC 228 ms
88,192 KB
testcase_09 AC 230 ms
88,448 KB
testcase_10 TLE -
testcase_11 AC 1,436 ms
232,692 KB
testcase_12 AC 359 ms
92,780 KB
testcase_13 TLE -
testcase_14 AC 2,004 ms
285,432 KB
testcase_15 AC 2,066 ms
284,668 KB
testcase_16 AC 1,575 ms
254,212 KB
testcase_17 AC 959 ms
176,892 KB
testcase_18 AC 1,034 ms
184,952 KB
testcase_19 AC 2,044 ms
285,040 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter, defaultdict
import math

def prime_numbers(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
primes = prime_numbers(10 ** 6 + 1)
def soinnsuu(x):
    s = []
    for i in primes:
        if i > int(math.sqrt(x)):
            break
        elif x % i == 0:
            while x % i == 0:
                x //= i
                s.append(i)
    if not x == 1:
        s.append(x)
    return Counter(s)
n = int(input())
Cs = []
for i in range(1, n):
    Cs.append(soinnsuu(i))
d = defaultdict(int)
for i in range(1, n):
    p1, p2 = Cs[i - 1], Cs[-i]
    for j in p1.keys() | p2.keys():
        d[j] = max(d[j], p1[j] + p2[j])
ans = 1
mod = 998244353
for k, v in d.items():
    ans *= pow(k, v, mod)
    ans %= mod
print(ans)
0