結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー soujikisoujiki
提出日時 2015-04-27 15:14:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 3,488 ms
コンパイル使用メモリ 71,872 KB
実行使用メモリ 55,892 KB
最終ジャッジ日時 2023-09-18 13:51:44
合計ジャッジ時間 7,686 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,688 KB
testcase_01 AC 121 ms
55,612 KB
testcase_02 AC 123 ms
55,828 KB
testcase_03 AC 122 ms
55,412 KB
testcase_04 AC 123 ms
55,848 KB
testcase_05 AC 121 ms
55,712 KB
testcase_06 AC 121 ms
55,600 KB
testcase_07 AC 124 ms
53,596 KB
testcase_08 AC 125 ms
55,628 KB
testcase_09 AC 126 ms
55,876 KB
testcase_10 AC 124 ms
55,696 KB
testcase_11 AC 126 ms
55,832 KB
testcase_12 AC 123 ms
55,772 KB
testcase_13 AC 124 ms
55,824 KB
testcase_14 AC 122 ms
55,600 KB
testcase_15 AC 122 ms
55,844 KB
testcase_16 AC 121 ms
55,772 KB
testcase_17 AC 120 ms
55,772 KB
testcase_18 AC 142 ms
55,676 KB
testcase_19 AC 122 ms
53,752 KB
testcase_20 AC 123 ms
55,892 KB
testcase_21 AC 123 ms
55,800 KB
testcase_22 AC 119 ms
55,892 KB
testcase_23 AC 120 ms
55,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Yukicoder_47{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		boolean flag = true;
		if(N==1){
			System.out.println(0);
		}
		else{
			String str = Integer.toBinaryString(N);
			int count = str.length();
			for(int i=1;i<str.length();i++){
				char ch = str.charAt(i);
				if(ch == '1'){
					flag = false;
				}
			}
			if(flag){
				System.out.println(count-1);
			}
			else{
				System.out.println(count);
			}
		}
	}
}
0