結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー sjgq5302sjgq5302
提出日時 2017-07-26 21:59:17
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-18 02:01:58
合計ジャッジ時間 3,263 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
12,288 KB
testcase_01 AC 93 ms
12,160 KB
testcase_02 AC 93 ms
12,160 KB
testcase_03 AC 92 ms
12,416 KB
testcase_04 AC 93 ms
12,288 KB
testcase_05 AC 93 ms
12,160 KB
testcase_06 AC 93 ms
12,160 KB
testcase_07 AC 95 ms
12,160 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 94 ms
12,160 KB
testcase_11 AC 94 ms
12,288 KB
testcase_12 AC 94 ms
12,416 KB
testcase_13 AC 92 ms
12,288 KB
testcase_14 AC 93 ms
12,288 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 94 ms
12,288 KB
testcase_18 AC 94 ms
12,288 KB
testcase_19 AC 94 ms
12,160 KB
testcase_20 AC 95 ms
12,288 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

biscuit = gets.to_i
n = 0

while 2**n < biscuit do #maxの枚数を超えるまで倍々
    n += 1
end

if 2**n == biscuit then #初期値からピッタリで終わる時
    puts n
elsif (biscuit - 2**(n-1)) == 1 #2の累乗より1多い時
    puts n
elsif ((biscuit - 2**(n-1)) % 2) == 0 #初期値からmaxの枚数を超えない回数で残りの枚数が偶数の時
    puts n
elsif ((biscuit - 2**(n-1)) % 2) == 1 #初期値からmaxの枚数を超えない回数で残りの枚数が奇数の時
    puts n + 1
end
0