結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー sasakkisasakki
提出日時 2016-04-08 11:49:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 536 bytes
コンパイル時間 2,158 ms
コンパイル使用メモリ 74,960 KB
実行使用メモリ 54,848 KB
最終ジャッジ日時 2024-04-14 23:27:11
合計ジャッジ時間 6,134 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
54,064 KB
testcase_01 AC 127 ms
54,108 KB
testcase_02 AC 121 ms
53,880 KB
testcase_03 AC 125 ms
53,992 KB
testcase_04 AC 124 ms
53,952 KB
testcase_05 AC 124 ms
53,984 KB
testcase_06 AC 124 ms
54,068 KB
testcase_07 AC 126 ms
53,892 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 124 ms
54,100 KB
testcase_11 AC 125 ms
54,188 KB
testcase_12 AC 125 ms
53,824 KB
testcase_13 AC 123 ms
54,116 KB
testcase_14 AC 124 ms
53,972 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 126 ms
53,900 KB
testcase_18 AC 114 ms
53,148 KB
testcase_19 AC 125 ms
54,012 KB
testcase_20 AC 126 ms
54,364 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class no47{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		int biscuits = 1;

		int num = 0;

		while(true){
			if( biscuits == N){
				break;
			}
			if( biscuits * 2 <= N ){
				biscuits *= 2;
				num++;
			}
			else{
				if( N - biscuits == 1){
					num++;
					break;
				}
				else if( (N - biscuits) % 2 == 0 ){
					num++;
					break;
				}
				else{
					num += 2;
					break;
				}
			}
		}

		System.out.println(num);

	}
}
0