結果

問題 No.2299 Antitypoglycemia
ユーザー 👑 obakyanobakyan
提出日時 2023-05-12 22:17:34
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 05:08:43
合計ジャッジ時間 1,495 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,380 KB
testcase_01 AC 7 ms
4,380 KB
testcase_02 AC 8 ms
4,380 KB
testcase_03 AC 8 ms
4,376 KB
testcase_04 AC 8 ms
4,380 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 8 ms
4,384 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 8 ms
4,384 KB
testcase_12 AC 8 ms
4,380 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 7 ms
4,384 KB
testcase_18 AC 8 ms
4,376 KB
testcase_19 AC 8 ms
4,376 KB
testcase_20 AC 8 ms
4,380 KB
testcase_21 AC 8 ms
4,376 KB
testcase_22 AC 8 ms
4,380 KB
testcase_23 AC 9 ms
4,376 KB
testcase_24 AC 8 ms
4,380 KB
testcase_25 AC 8 ms
4,376 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 8 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mod = 998244353
local mfl = math.floor
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 function badd(x, y)
  return (x + y) % mod
end

local fact = {1}
for i = 2, 200010 do
  fact[i] = bmul(fact[i - 1], i)
end

local n, a, b = io.read("*n", "*n", "*n")
local tot = fact[n]
local nota = fact[n - 1]
if a == b then
  print((tot + mod * 2 - nota * 2) % mod)
else
  if n == 2 then
    print(1)
  else
    local c = fact[n - 2]
    print((tot + mod * 4 - nota * 2 + c) % mod)
  end
end
0