結果

問題 No.3 ビットすごろく
ユーザー Ryuji_techRyuji_tech
提出日時 2016-03-30 23:50:40
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 450 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-04-10 06:38:13
合計ジャッジ時間 7,396 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
12,288 KB
testcase_01 AC 87 ms
12,160 KB
testcase_02 AC 85 ms
12,416 KB
testcase_03 AC 89 ms
12,544 KB
testcase_04 AC 86 ms
12,160 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
count = 1
tmp = 0
flag = 0

num = 1
while num < N && flag == 0 do

  num_2 = num.to_s(2)

  num_bit = 0

  s = num_2.split("")

  s.each do |i|
	  if i == "1"
		  num_bit = num_bit + 1
	  end
  end

  num = num + num_bit

	if num > N
    if tmp == num
      count = -1
      print count
      flag = 1
    end
    tmp = num
		num = num - num_bit * 2
		count = count + 1
	else
    count = count + 1
	end
end
if num == N
  print count
end
0