結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー kuramubonnkuramubonn
提出日時 2023-02-01 23:05:10
言語 Java19
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 389 bytes
コンパイル時間 2,665 ms
コンパイル使用メモリ 73,936 KB
実行使用メモリ 56,108 KB
最終ジャッジ日時 2023-09-14 08:42:20
合計ジャッジ時間 7,104 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
56,044 KB
testcase_01 AC 127 ms
55,664 KB
testcase_02 AC 125 ms
56,108 KB
testcase_03 AC 127 ms
55,856 KB
testcase_04 AC 124 ms
55,832 KB
testcase_05 AC 122 ms
55,856 KB
testcase_06 AC 126 ms
55,896 KB
testcase_07 AC 124 ms
56,104 KB
testcase_08 AC 123 ms
55,480 KB
testcase_09 AC 123 ms
55,768 KB
testcase_10 AC 124 ms
55,760 KB
testcase_11 AC 123 ms
55,992 KB
testcase_12 AC 125 ms
55,948 KB
testcase_13 AC 129 ms
55,732 KB
testcase_14 AC 130 ms
55,872 KB
testcase_15 AC 125 ms
55,500 KB
testcase_16 AC 124 ms
55,536 KB
testcase_17 AC 125 ms
55,752 KB
testcase_18 AC 126 ms
55,768 KB
testcase_19 AC 126 ms
55,692 KB
testcase_20 AC 127 ms
55,876 KB
testcase_21 AC 125 ms
55,968 KB
testcase_22 AC 125 ms
55,728 KB
testcase_23 AC 125 ms
55,876 KB
権限があれば一括ダウンロードができます

ソースコード

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