結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-05 11:25:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 473 bytes
コンパイル時間 3,470 ms
コンパイル使用メモリ 72,524 KB
実行使用メモリ 56,264 KB
最終ジャッジ日時 2023-09-21 00:53:56
合計ジャッジ時間 7,326 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,096 KB
testcase_01 AC 123 ms
56,020 KB
testcase_02 AC 124 ms
56,176 KB
testcase_03 AC 124 ms
56,044 KB
testcase_04 AC 121 ms
56,008 KB
testcase_05 AC 121 ms
56,136 KB
testcase_06 AC 123 ms
56,140 KB
testcase_07 AC 122 ms
55,956 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 124 ms
56,076 KB
testcase_11 AC 122 ms
56,064 KB
testcase_12 AC 124 ms
56,180 KB
testcase_13 AC 124 ms
55,808 KB
testcase_14 AC 123 ms
55,836 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 123 ms
56,160 KB
testcase_18 AC 125 ms
55,812 KB
testcase_19 AC 122 ms
56,160 KB
testcase_20 AC 122 ms
56,056 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No47 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); // 食べたいビスケットの枚数
		int x = 0; // ポケットを叩く回数
		int sum = 1; //持っているビスケットの枚数
		
		while((sum * 2) < N) {
			x++;
			sum *= 2;
		}
		
		if(N == sum) {
		}else if(N - sum == 1 || N % 2 == 0) {
			x++;
		}else {
			x += 2;
		}
		
		System.out.println(x);
	}
}
0