結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー oyafusooyafuso
提出日時 2019-03-15 11:44:18
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 963 bytes
コンパイル時間 2,824 ms
コンパイル使用メモリ 73,004 KB
実行使用メモリ 837,128 KB
最終ジャッジ日時 2023-09-11 02:41:22
合計ジャッジ時間 7,067 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

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(N);
		/* メイン処理終了 */

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

	private static int count(int num) {
		int total = 1;
		int add = total;
		int result = 0;
		while (total != num) {
			if ((total += add) <= num) {
				total += add;
				add += add;
				result++;
			} else {
				result = count(num / total);
				break;
			}
		}
		return result;
	}
}
0