結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー kuramubonn
提出日時 2023-02-01 23:05:10
言語 Java
(openjdk 23)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 389 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 74,668 KB
実行使用メモリ 41,660 KB
最終ジャッジ日時 2024-07-01 16:03:11
合計ジャッジ時間 6,314 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt(),count = 0;
		
		if(num == 1) {
			System.out.println(0);
			return;
		}
		
		int c = 1;
		while(true) {
				if(num - c <= c) {
					System.out.println(count + 1);
					return;
				}
				if(num - c > c) {
					c *= 2;
					count++;
				}
		}
	}
}
0