結果

問題 No.3 ビットすごろく
コンテスト
ユーザー iceEiji2
提出日時 2016-11-15 00:57:51
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
WA  
実行時間 -
コード長 364 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 228 ms
コンパイル使用メモリ 8,960 KB
実行使用メモリ 14,976 KB
最終ジャッジ日時 2026-05-20 13:47:50
合計ジャッジ時間 3,387 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

gole = gets.to_i
current = 1
root_count = 1

until current >= gole do
  move = current.to_s(2).count("1")
  root_count += 1
  if root_count > gole then
    root_count = -1
    break
  elsif current + move == gole then
    break
  elsif current + move > gole then
    current -= move
  elsif current + move < gole then
    current += move
  end
end
puts root_count
0