結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー ShotaroSuzu
提出日時 2020-05-19 18:46:30
言語 Java
(openjdk 23)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 566 bytes
コンパイル時間 3,264 ms
コンパイル使用メモリ 74,824 KB
実行使用メモリ 54,440 KB
最終ジャッジ日時 2024-10-01 22:57:09
合計ジャッジ時間 7,439 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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