結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー oyafusooyafuso
提出日時 2019-03-15 16:52:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 966 bytes
コンパイル時間 3,766 ms
コンパイル使用メモリ 72,160 KB
実行使用メモリ 55,868 KB
最終ジャッジ日時 2023-09-14 12:33:46
合計ジャッジ時間 7,350 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,772 KB
testcase_01 AC 127 ms
55,720 KB
testcase_02 AC 128 ms
55,316 KB
testcase_03 AC 125 ms
55,500 KB
testcase_04 AC 127 ms
55,412 KB
testcase_05 AC 128 ms
55,480 KB
testcase_06 AC 127 ms
55,652 KB
testcase_07 AC 126 ms
55,616 KB
testcase_08 AC 126 ms
55,560 KB
testcase_09 AC 126 ms
55,640 KB
testcase_10 AC 124 ms
55,852 KB
testcase_11 AC 126 ms
55,536 KB
testcase_12 AC 129 ms
55,868 KB
testcase_13 AC 126 ms
55,848 KB
testcase_14 AC 128 ms
55,824 KB
testcase_15 AC 125 ms
55,580 KB
testcase_16 AC 128 ms
55,584 KB
testcase_17 AC 127 ms
55,480 KB
testcase_18 AC 129 ms
55,832 KB
testcase_19 AC 126 ms
55,684 KB
testcase_20 AC 126 ms
55,580 KB
testcase_21 AC 127 ms
55,532 KB
testcase_22 AC 127 ms
55,492 KB
testcase_23 AC 126 ms
55,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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