結果

問題 No.1529 Constant Lcm
ユーザー brthyyjpbrthyyjp
提出日時 2021-07-19 02:32:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,077 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 11,092 KB
実行使用メモリ 468,528 KB
最終ジャッジ日時 2023-09-23 06:07:25
合計ジャッジ時間 9,096 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 249 ms
52,284 KB
testcase_01 AC 275 ms
48,648 KB
testcase_02 AC 247 ms
47,776 KB
testcase_03 AC 254 ms
47,824 KB
testcase_04 AC 256 ms
47,636 KB
testcase_05 AC 256 ms
47,764 KB
testcase_06 AC 256 ms
47,652 KB
testcase_07 AC 249 ms
47,612 KB
testcase_08 AC 265 ms
47,660 KB
testcase_09 AC 256 ms
47,820 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

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