結果
問題 | No.47 ポケットを叩くとビスケットが2倍 |
ユーザー |
|
提出日時 | 2016-01-28 01:26:14 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 85 ms / 5,000 ms |
コード長 | 217 bytes |
コンパイル時間 | 58 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-09-21 17:45:08 |
合計ジャッジ時間 | 2,706 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
Syntax OK
ソースコード
def chop(n, base=1) count = 0 while n >= base break if n < base * 2 base <<= 1 count += 1 end count end n = gets.to_i count = chop(n) m = 1 << count count += 1 if n-m <= m and n-m > 0 puts count