結果
| 問題 |
No.1286 Stone Skipping
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-08-18 13:52:27 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 618 bytes |
| コンパイル時間 | 84 ms |
| コンパイル使用メモリ | 6,948 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-06 04:21:21 |
| 合計ジャッジ時間 | 1,224 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
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 d = io.read()
d = lltonumber(d)
local ans = d
local function solve(x, rep)
local ret = x
for i = 1, rep do
x = x / 2LL
ret = ret + x
end
return ret
end
for i = 1, 64 do
local min = 0LL
local max = d
while 1LL < max - min do
local mid = (min + max) / 2LL
if d <= solve(mid, i) then
max = mid
else
min = mid
end
end
if d == solve(max, i) then
ans = max
end
end
ans = tostring(ans):gsub("LL", "")
print(ans)