結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー aparachia14aparachia14
提出日時 2016-01-16 00:20:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,056 bytes
コンパイル時間 4,325 ms
コンパイル使用メモリ 74,844 KB
実行使用メモリ 53,528 KB
最終ジャッジ日時 2023-10-19 23:48:57
合計ジャッジ時間 6,515 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,524 KB
testcase_01 AC 56 ms
53,528 KB
testcase_02 AC 55 ms
52,404 KB
testcase_03 AC 57 ms
53,512 KB
testcase_04 AC 56 ms
53,524 KB
testcase_05 AC 57 ms
53,524 KB
testcase_06 AC 56 ms
52,544 KB
testcase_07 AC 58 ms
53,524 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 57 ms
52,540 KB
testcase_11 AC 57 ms
53,524 KB
testcase_12 AC 56 ms
53,524 KB
testcase_13 AC 56 ms
53,528 KB
testcase_14 AC 56 ms
52,412 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 57 ms
53,516 KB
testcase_18 AC 57 ms
53,516 KB
testcase_19 AC 57 ms
52,432 KB
testcase_20 AC 56 ms
53,516 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//No.47 ポケットを叩くとビスケットが2倍
public class TwiceBiscuit {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		//食べたいビスケットの枚数
		int want;
		//ビスケットの枚数
		int biscuit = 1;
		//カウンタ
		int counter = 0;
		
		//入力受け取り
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		want = Integer.parseInt(in.readLine());
		
		while(true){
			biscuit = biscuit * 2;
			if(biscuit > want){
				break;
			}else{
				
			}
			counter++;
		}
		
		//あと欲しい数
		int want2 = want - (biscuit / 2);
		//want2を2で割った余りが0ならcounterに+1 余りが1ならcounterに+2
		if(want2 == 0){
			
		}else if(want2 == 1){
			counter++;
	    }else if(want2 % 2 == 0){
			counter++;
		}else if(want2 % 2 == 1){
			counter = counter + 2;
		}else{
			
		}
		
		System.out.println(counter);

	}

}
0