結果
問題 | No.1529 Constant Lcm |
ユーザー | wolgnik |
提出日時 | 2021-06-04 20:42:57 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,146 bytes |
コンパイル時間 | 279 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 68,736 KB |
最終ジャッジ日時 | 2024-04-30 00:19:54 |
合計ジャッジ時間 | 5,298 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
57,856 KB |
testcase_01 | AC | 79 ms
68,736 KB |
testcase_02 | AC | 43 ms
52,352 KB |
testcase_03 | AC | 41 ms
52,352 KB |
testcase_04 | AC | 42 ms
52,096 KB |
testcase_05 | AC | 41 ms
52,096 KB |
testcase_06 | AC | 42 ms
52,096 KB |
testcase_07 | AC | 42 ms
52,480 KB |
testcase_08 | AC | 41 ms
52,096 KB |
testcase_09 | AC | 42 ms
52,480 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 | -- | - |
ソースコード
import sys input = sys.stdin.readline N = int(input()) mod = 998244353 class sieve: def __init__(self, n): self.n = n self.sv = [1] * (n + 1) self.sv[0] = 0 self.sv[1] = 0 for i in range(2, n + 1): if self.sv[i]: for j in range(i * 2, n + 1, i): self.sv[j] = 0 def isprime(self, x): if x > self.n: return False return self.sv[x] == 1 def factorize(self, x): res = [] for i in range(2, int(x ** 0.5) + 1): if self.sv[i]: while x % i == 0: x //= i res.append(i) if x != 1: res.append(x) return res def modlcm(self, a, mod): res = [0] * (self.n + 1) ex = set() for i in range(len(a)): f = self.factorize(a[i]) for j in f: if j > self.n: ex.add(j) continue res[j] = max(f.count(j), res[j]) rres = 1 for i in range(self.n + 1): if res[i] != 0: rres *= pow(i, res[i], mod) rres %= mod for i in ex: rres *= i rres %= mod return rres sv = sieve(N) a = [x * (N - x) for x in range(1, N // 2 + 1)] print(sv.modlcm(a, mod))