結果

問題 No.1529 Constant Lcm
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-06-04 21:04:44
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 2,294 ms / 3,000 ms
コード長 1,174 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 86,800 KB
実行使用メモリ 214,192 KB
最終ジャッジ日時 2023-08-12 10:45:26
合計ジャッジ時間 27,568 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 225 ms
89,836 KB
testcase_01 AC 260 ms
89,828 KB
testcase_02 AC 205 ms
89,912 KB
testcase_03 AC 196 ms
90,052 KB
testcase_04 AC 206 ms
89,700 KB
testcase_05 AC 212 ms
89,716 KB
testcase_06 AC 216 ms
89,760 KB
testcase_07 AC 202 ms
89,828 KB
testcase_08 AC 201 ms
89,768 KB
testcase_09 AC 201 ms
89,796 KB
testcase_10 AC 1,959 ms
202,884 KB
testcase_11 AC 857 ms
132,616 KB
testcase_12 AC 300 ms
90,444 KB
testcase_13 AC 1,705 ms
186,780 KB
testcase_14 AC 1,130 ms
150,840 KB
testcase_15 AC 1,216 ms
154,816 KB
testcase_16 AC 972 ms
139,204 KB
testcase_17 AC 648 ms
116,296 KB
testcase_18 AC 645 ms
117,812 KB
testcase_19 AC 1,150 ms
153,372 KB
testcase_20 AC 2,223 ms
214,032 KB
testcase_21 AC 2,144 ms
213,668 KB
testcase_22 AC 2,258 ms
213,744 KB
testcase_23 AC 2,161 ms
212,880 KB
testcase_24 AC 2,294 ms
214,192 KB
testcase_25 AC 2,139 ms
214,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from collections import Counter
    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 s
    n = int(input())
    Cs = [soinnsuu(i) for i in range(1, n)]
    d = dict()
    for i in range(1, (n + 1) // 2 + 1):
        p1, p2 = Counter(Cs[i - 1]), Counter(Cs[-i])
        for j in p1.keys() | p2.keys():
            if not j in d: d[j] = p1[j] + p2[j]
            else: 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)
if __name__ == '__main__':
    main()
0