結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-04 18:52:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 370 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 74,380 KB
実行使用メモリ 57,544 KB
最終ジャッジ日時 2023-10-21 19:12:39
合計ジャッジ時間 6,388 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,352 KB
testcase_01 AC 133 ms
57,368 KB
testcase_02 AC 137 ms
57,064 KB
testcase_03 AC 133 ms
57,316 KB
testcase_04 AC 134 ms
57,544 KB
testcase_05 AC 131 ms
57,316 KB
testcase_06 AC 131 ms
57,364 KB
testcase_07 AC 132 ms
57,380 KB
testcase_08 AC 134 ms
57,544 KB
testcase_09 AC 135 ms
57,352 KB
testcase_10 AC 135 ms
57,312 KB
testcase_11 AC 133 ms
57,352 KB
testcase_12 AC 134 ms
57,352 KB
testcase_13 AC 133 ms
57,440 KB
testcase_14 AC 134 ms
57,308 KB
testcase_15 AC 134 ms
57,344 KB
testcase_16 AC 133 ms
57,268 KB
testcase_17 AC 132 ms
57,260 KB
testcase_18 AC 133 ms
57,344 KB
testcase_19 AC 134 ms
57,160 KB
testcase_20 AC 132 ms
57,176 KB
testcase_21 AC 131 ms
57,368 KB
testcase_22 AC 131 ms
57,332 KB
testcase_23 AC 130 ms
57,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Test {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();

		int num = 1;
		int counts = 0;

		while(true) {
			num *= 2;
			if(num > n) {
				break;
			}
			counts++;
		}

		int w = n - (num / 2);
		if(w != 0) {
			counts++;
		}

		System.out.println(counts);
	}
}
0