結果

問題 No.1958 Bit Game
ユーザー 👑 obakyanobakyan
提出日時 2022-10-07 13:01:32
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 5,260 KB
実行使用メモリ 6,512 KB
最終ジャッジ日時 2023-09-02 13:49:12
合計ジャッジ時間 13,919 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 435 ms
6,412 KB
testcase_01 AC 433 ms
6,512 KB
testcase_02 AC 439 ms
6,364 KB
testcase_03 AC 429 ms
6,364 KB
testcase_04 AC 434 ms
6,304 KB
testcase_05 AC 433 ms
6,348 KB
testcase_06 AC 427 ms
6,348 KB
testcase_07 AC 428 ms
6,232 KB
testcase_08 AC 428 ms
6,408 KB
testcase_09 AC 425 ms
6,428 KB
testcase_10 AC 131 ms
4,384 KB
testcase_11 AC 211 ms
5,408 KB
testcase_12 AC 201 ms
5,352 KB
testcase_13 AC 281 ms
4,784 KB
testcase_14 AC 263 ms
4,396 KB
testcase_15 AC 131 ms
6,424 KB
testcase_16 AC 75 ms
5,472 KB
testcase_17 AC 355 ms
6,388 KB
testcase_18 AC 283 ms
6,448 KB
testcase_19 AC 122 ms
5,388 KB
testcase_20 AC 360 ms
5,252 KB
testcase_21 AC 171 ms
6,364 KB
testcase_22 AC 207 ms
4,384 KB
testcase_23 AC 98 ms
4,828 KB
testcase_24 AC 367 ms
5,412 KB
testcase_25 AC 138 ms
4,384 KB
testcase_26 AC 320 ms
4,764 KB
testcase_27 AC 106 ms
6,280 KB
testcase_28 AC 356 ms
5,408 KB
testcase_29 AC 196 ms
4,384 KB
testcase_30 AC 2 ms
4,384 KB
testcase_31 AC 1 ms
4,384 KB
testcase_32 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local n, x, y = io.read("*n", "*n", "*n")
local a = {}
local b = {}
for i = 1, x do
  a[i] = io.read("*n")
end
for i = 1, y do
  b[i] = io.read("*n")
end
local at, bt = {}, {}
for i = 1, 18 do
  local v = 0
  for j = 1, x do
    v = v + (a[j] % 2)
    a[j] = mfl(a[j] / 2)
  end
  at[i] = v
  v = 0
  for j = 1, y do
    v = v + (b[j] % 2)
    b[j] = mfl(b[j] / 2)
  end
  bt[i] = v
end
local ret = 0
local mul = 1
for i = 1, 18 do
  local zero, one = 1, 0
  for rep = 1, n do
    zero, one = bmul(zero, x - at[i]), badd(bmul(zero, at[i]), bmul(one, x))
    zero, one = badd(bmul(zero, y), bmul(one, y - bt[i])), bmul(one, bt[i])
  end
  ret = badd(ret, bmul(mul, one))
  mul = mul * 2
end
print(ret)
0