結果

問題 No.1286 Stone Skipping
ユーザー simansiman
提出日時 2021-01-01 13:30:52
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 267 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-10-11 02:30:44
合計ジャッジ時間 3,845 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

D = gets.to_i

def f(x)
  len = 0

  while x > 0 && len < D
    len += x
    x /= 2
  end

  len
end

ng = 0
ok = 10 ** 18

while (ok - ng).abs >= 2
  x = (ok + ng) / 2

  if D <= f(x)
    ok = x
  else
    ng = x
  end
end

if f(ok) != D
  puts D
else
  puts ok
end
0