結果
問題 | No.1529 Constant Lcm |
ユーザー | 👑 obakyan |
提出日時 | 2022-03-27 00:25:11 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
AC
|
実行時間 | 1,349 ms / 3,000 ms |
コード長 | 1,320 bytes |
コンパイル時間 | 49 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 188,220 KB |
最終ジャッジ日時 | 2024-04-23 15:25:07 |
合計ジャッジ時間 | 14,305 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 1,219 ms
170,028 KB |
testcase_11 | AC | 379 ms
69,248 KB |
testcase_12 | AC | 14 ms
6,940 KB |
testcase_13 | AC | 1,018 ms
148,328 KB |
testcase_14 | AC | 552 ms
87,124 KB |
testcase_15 | AC | 651 ms
107,244 KB |
testcase_16 | AC | 473 ms
80,260 KB |
testcase_17 | AC | 209 ms
43,616 KB |
testcase_18 | AC | 232 ms
46,720 KB |
testcase_19 | AC | 593 ms
92,020 KB |
testcase_20 | AC | 1,331 ms
184,124 KB |
testcase_21 | AC | 1,339 ms
185,720 KB |
testcase_22 | AC | 1,349 ms
186,196 KB |
testcase_23 | AC | 1,349 ms
188,220 KB |
testcase_24 | AC | 1,331 ms
187,164 KB |
testcase_25 | AC | 1,324 ms
181,612 KB |
ソースコード
local mmi, mma = math.min, math.max local mfl, mce = math.floor, math.ceil local mod = 998244353 local function bmul(x, y) local x0, y0 = x % 31596, y % 31596 local x1, y1 = mfl(x / 31596), mfl(y / 31596) return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod end local n = io.read("*n") n = n - 1 local t = {} local box = {} for i = 1, n do t[i] = i box[i] = {} end local function put(dst, val, cnt) local d = dst * 2 <= n and dst or n + 1 - dst if not box[d][val] then box[d][val] = cnt else box[d][val] = box[d][val] + cnt end end for i = 1, n do local v = t[i] if 1 < v then local lim = mfl(n / i) for j = 1, lim do local dst = i * j local c = 0 while t[dst] % v == 0 do t[dst] = mfl(t[dst] / v) c = c + 1 end if 0 < c then put(dst, v, c) end end end end local half = mce(n / 2) if n % 2 == 1 then for k, v in pairs(box[half]) do box[half][k] = v * 2 end end local fullbox = {} for i = 1, half do for k, v in pairs(box[i]) do -- print(i, k, v) if not fullbox[k] then fullbox[k] = v else fullbox[k] = mma(fullbox[k], v) end end end local ret = 1 for k, v in pairs(fullbox) do -- print(k, v) for i = 1, v do ret = bmul(ret, k) end end print(ret)