結果

問題 No.47 ポケットを叩くとビスケットが2倍
コンテスト
ユーザー oyafuso
提出日時 2019-03-15 16:52:07
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 966 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,151 ms
コンパイル使用メモリ 83,912 KB
実行使用メモリ 43,480 KB
最終ジャッジ日時 2026-03-22 21:50:52
合計ジャッジ時間 4,383 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.*;

class Main {

	private static final String SPLIT_STR = " ";

	public static void main(String[] args) {
		// Scanner生成
		Scanner sc = new Scanner(System.in);
		// 入力設定
		String input = sc.nextLine();
		String[] split = input.split(SPLIT_STR);
		List<Integer> numList = new ArrayList<>(split.length);
		for (int i = 0; i < split.length; i++) {
			numList.add(Integer.parseInt(split[i]));
		}
		// Scannerクローズ
		sc.close();

		/* メイン処理開始 */
		// 変数初期化
		int result = 0;
		int N = numList.get(0);
		// 結果設定
		result = count(1, N);
		/* メイン処理終了 */

		// 結果出力
		System.out.println(result);
	}

	private static int count(int beginNum, int endNum) {
		int result = 0;
		int total = 1;
		while (total < endNum) {
			if ((total + total) > endNum ) {
				total += endNum - total;
				result++;
				break;
			} else {
				total += total;
				result++;
			}
		}
		return result;
	}
}
0