結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー 37zigen37zigen
提出日時 2016-04-01 15:17:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 345 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 74,308 KB
実行使用メモリ 54,328 KB
最終ジャッジ日時 2024-04-10 07:05:11
合計ジャッジ時間 5,897 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
54,020 KB
testcase_01 AC 124 ms
54,184 KB
testcase_02 AC 127 ms
54,068 KB
testcase_03 AC 127 ms
54,024 KB
testcase_04 AC 127 ms
54,020 KB
testcase_05 AC 125 ms
53,892 KB
testcase_06 AC 127 ms
54,096 KB
testcase_07 AC 125 ms
54,224 KB
testcase_08 AC 126 ms
54,208 KB
testcase_09 AC 124 ms
54,112 KB
testcase_10 AC 126 ms
53,940 KB
testcase_11 AC 113 ms
53,004 KB
testcase_12 AC 126 ms
54,124 KB
testcase_13 AC 130 ms
54,008 KB
testcase_14 AC 111 ms
52,756 KB
testcase_15 AC 111 ms
52,724 KB
testcase_16 AC 124 ms
54,264 KB
testcase_17 AC 123 ms
54,164 KB
testcase_18 AC 122 ms
54,136 KB
testcase_19 AC 122 ms
53,960 KB
testcase_20 AC 123 ms
54,116 KB
testcase_21 AC 124 ms
54,124 KB
testcase_22 AC 124 ms
54,232 KB
testcase_23 AC 127 ms
54,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder047;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int sum=1;
		int count=0;
		while(sum!=n){
			if(sum*2<=n){
				sum*=2;
				count++;
			}else if(sum*2>n){
				sum=n;
				count++;
			}
		}
		System.out.println(count);

	}
}
0