結果

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

ソースコード

diff #

D = gets.to_i

def f(x)
  len = 0

  while x > 0
    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