結果

問題 No.1529 Constant Lcm
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-06-04 20:45:25
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,164 bytes
コンパイル時間 1,596 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 214,788 KB
最終ジャッジ日時 2023-08-12 10:09:17
合計ジャッジ時間 42,697 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 222 ms
90,040 KB
testcase_01 AC 291 ms
89,840 KB
testcase_02 AC 228 ms
90,168 KB
testcase_03 AC 224 ms
90,136 KB
testcase_04 AC 238 ms
89,988 KB
testcase_05 AC 222 ms
90,104 KB
testcase_06 AC 223 ms
90,092 KB
testcase_07 AC 225 ms
90,072 KB
testcase_08 AC 228 ms
89,964 KB
testcase_09 AC 222 ms
89,904 KB
testcase_10 TLE -
testcase_11 AC 1,286 ms
132,888 KB
testcase_12 AC 346 ms
90,464 KB
testcase_13 AC 2,660 ms
187,256 KB
testcase_14 AC 1,734 ms
151,252 KB
testcase_15 AC 1,867 ms
155,156 KB
testcase_16 AC 1,459 ms
139,264 KB
testcase_17 AC 886 ms
116,424 KB
testcase_18 AC 917 ms
118,232 KB
testcase_19 AC 1,826 ms
153,776 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
権限があれば一括ダウンロードができます

ソースコード

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):
        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