結果

問題 No.2393 Bit Grid Connected Component
ユーザー 👑 obakyanobakyan
提出日時 2023-07-29 07:54:06
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 5,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 14:51:08
合計ジャッジ時間 2,217 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 9 ms
5,376 KB
testcase_15 AC 11 ms
5,376 KB
testcase_16 AC 75 ms
5,376 KB
testcase_17 AC 203 ms
5,376 KB
testcase_18 AC 209 ms
5,376 KB
testcase_19 AC 254 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local ffi = require("ffi")
local C = ffi.C
ffi.cdef[[
long long atoll(const char*);
]]

local function lltonumber(str)
  return C.atoll(str)
end

local q = io.read("*n", "*l")
for iq = 1, q do
  local x, y = io.read():match("(%d+) (%d+)")
  x = lltonumber(x)
  y = tonumber(y)
  local c = y
  for i = 1, y do
    x = x / 2LL
  end
  while x % 2LL == 1LL do
    c = c + 1
    x = x / 2LL
  end
  local ans = 1LL
  for i = 1, c do
    ans = ans + ans
  end
  ans = ans - 1LL
  ans = tostring(ans):gsub("LL", "")
  print(ans)
end
0