結果

問題 No.262 面白くないビットすごろく
ユーザー eigh8_teigh8_t
提出日時 2015-07-31 23:05:06
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 218 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 11,256 KB
実行使用メモリ 19,564 KB
最終ジャッジ日時 2023-09-24 23:01:13
合計ジャッジ時間 3,690 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
19,564 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:20: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

n = gets.to_i
sum = 1
i = 1
count = 1
while sum < n
	i = sum
	j = 1
	while i >= j
		sum += 1 if j & i > 0
		j *= 2
	end
	i += 1
	count += 1
	flug = true if sum == n
end

if flug || n == 1
	puts count
else
	puts -1
end
0