結果

問題 No.1529 Constant Lcm
ユーザー brthyyjpbrthyyjp
提出日時 2021-06-07 22:14:24
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,078 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 86,704 KB
実行使用メモリ 668,676 KB
最終ジャッジ日時 2023-08-16 14:41:12
合計ジャッジ時間 34,252 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
84,756 KB
testcase_01 AC 165 ms
85,812 KB
testcase_02 AC 123 ms
84,504 KB
testcase_03 AC 125 ms
84,456 KB
testcase_04 AC 119 ms
84,668 KB
testcase_05 AC 125 ms
84,516 KB
testcase_06 AC 122 ms
84,580 KB
testcase_07 AC 123 ms
84,568 KB
testcase_08 AC 124 ms
84,764 KB
testcase_09 AC 119 ms
84,764 KB
testcase_10 MLE -
testcase_11 AC 1,017 ms
297,204 KB
testcase_12 AC 192 ms
96,996 KB
testcase_13 MLE -
testcase_14 AC 1,395 ms
378,772 KB
testcase_15 AC 1,449 ms
396,880 KB
testcase_16 AC 1,071 ms
327,268 KB
testcase_17 AC 596 ms
217,668 KB
testcase_18 AC 636 ms
228,180 KB
testcase_19 AC 1,497 ms
387,464 KB
testcase_20 MLE -
testcase_21 TLE -
testcase_22 MLE -
testcase_23 MLE -
testcase_24 TLE -
testcase_25 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def main():

    N = 10**6+1
    spf = [-1]*(N+1)
    for i in range(N+1):
        spf[i] = i
    for i in range(2, int(math.sqrt(N))+1):
        if spf[i] == i:
            for j in range(i*2, N+1, i):
                if spf[j] == j:
                    spf[j] = i

    def factorize(n):
        d = {}
        while n != 1:
            p = spf[n]
            if p in d:
                d[p] += 1
            else:
                d[p] = 1
            n //= p
        return d

    n = int(input())

    mod = 998244353
    from collections import defaultdict
    D = [defaultdict(lambda: 0) for i in range(n)]
    for i in range(1, n):
        if i == 1:
            continue
        d = factorize(i)
        for k, v in d.items():
            D[i][k] += v
            D[n-i][k] += v
    P = defaultdict(lambda: 0)
    for i in range(1, n):
        d = D[i]
        for k, v in d.items():
            P[k] = max(P[k], v)
    ans = 1
    for k, v in P.items():
        ans *= pow(k, v, mod)
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()
0