結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー sasakki
提出日時 2016-04-08 11:49:39
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 536 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 75,052 KB
実行使用メモリ 54,344 KB
最終ジャッジ日時 2024-10-04 04:49:13
合計ジャッジ時間 5,923 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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