結果

問題 No.2233 Average
ユーザー 👑 obakyanobakyan
提出日時 2023-05-06 10:19:15
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 413 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 00:01:39
合計ジャッジ時間 4,946 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 238 ms
5,376 KB
testcase_09 AC 367 ms
5,376 KB
testcase_10 AC 265 ms
5,376 KB
testcase_11 AC 243 ms
5,376 KB
testcase_12 AC 215 ms
5,376 KB
testcase_13 AC 49 ms
5,376 KB
testcase_14 AC 202 ms
5,376 KB
testcase_15 AC 284 ms
5,376 KB
testcase_16 AC 76 ms
5,376 KB
testcase_17 AC 99 ms
5,376 KB
testcase_18 AC 413 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 n = io.read("*n", "*l")
for i = 1, n do
  local a, b, c, k = io.read():match("(%d+) (%d+) (%d+) (%d+)")
  a = lltonumber(a)
  b = lltonumber(b)
  c = lltonumber(c)
  k = lltonumber(k)
  while 0LL < k and (a ~= b or b ~= c) do
    k = k - 1LL
    a, b, c = (b + c) / 2LL, (c + a) / 2LL, (a + b) / 2LL
  end
  local ans = (a + b + c)
  ans = tostring(ans):gsub("LL", "")
  print(ans)
end
0