結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー ShotaroSuzuShotaroSuzu
提出日時 2020-05-19 18:46:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 113 ms / 5,000 ms
コード長 566 bytes
コンパイル時間 2,941 ms
コンパイル使用メモリ 75,720 KB
実行使用メモリ 54,296 KB
最終ジャッジ日時 2024-04-09 22:22:14
合計ジャッジ時間 6,237 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
53,768 KB
testcase_01 AC 110 ms
54,272 KB
testcase_02 AC 99 ms
52,816 KB
testcase_03 AC 111 ms
54,124 KB
testcase_04 AC 109 ms
54,168 KB
testcase_05 AC 99 ms
53,012 KB
testcase_06 AC 109 ms
54,124 KB
testcase_07 AC 112 ms
54,248 KB
testcase_08 AC 108 ms
54,220 KB
testcase_09 AC 107 ms
54,156 KB
testcase_10 AC 109 ms
54,248 KB
testcase_11 AC 100 ms
53,300 KB
testcase_12 AC 98 ms
53,028 KB
testcase_13 AC 98 ms
52,948 KB
testcase_14 AC 105 ms
54,296 KB
testcase_15 AC 106 ms
53,988 KB
testcase_16 AC 110 ms
53,896 KB
testcase_17 AC 98 ms
52,804 KB
testcase_18 AC 107 ms
54,272 KB
testcase_19 AC 105 ms
54,120 KB
testcase_20 AC 105 ms
53,832 KB
testcase_21 AC 111 ms
54,108 KB
testcase_22 AC 109 ms
54,180 KB
testcase_23 AC 107 ms
54,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder.beginner.pocketbiscuit;

import java.util.Scanner;

public class PocketBiscuit {

	public static void main(String[] args) {
		new PocketBiscuit().execute();
	}

	private void execute() {
		long cookieNum = read();

		long hitNum = 0;
		while(Math.pow(2, hitNum + 1) < cookieNum) {
			hitNum++;
		}
		if(Math.pow(2, hitNum) == cookieNum) {
			System.out.println(hitNum);
		} else {
			System.out.println(hitNum + 1);
		}
	}

	private long read() {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		return sc.nextLong();
	}

}
0