結果

問題 No.1869 Doubling?
ユーザー ks2mks2m
提出日時 2022-03-11 22:19:06
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 507 bytes
コンパイル時間 4,318 ms
コンパイル使用メモリ 71,752 KB
実行使用メモリ 57,952 KB
最終ジャッジ日時 2023-10-14 07:30:22
合計ジャッジ時間 10,399 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,776 KB
testcase_01 AC 134 ms
55,568 KB
testcase_02 AC 133 ms
55,564 KB
testcase_03 AC 132 ms
55,868 KB
testcase_04 AC 133 ms
55,808 KB
testcase_05 AC 132 ms
55,728 KB
testcase_06 AC 133 ms
55,812 KB
testcase_07 AC 132 ms
55,740 KB
testcase_08 AC 135 ms
55,836 KB
testcase_09 WA -
testcase_10 AC 136 ms
55,736 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 131 ms
55,780 KB
testcase_16 AC 132 ms
55,776 KB
testcase_17 AC 132 ms
55,524 KB
testcase_18 AC 135 ms
55,576 KB
testcase_19 AC 134 ms
55,816 KB
testcase_20 AC 133 ms
55,944 KB
testcase_21 AC 136 ms
55,516 KB
testcase_22 AC 131 ms
55,844 KB
testcase_23 AC 137 ms
55,792 KB
testcase_24 AC 134 ms
55,740 KB
testcase_25 AC 134 ms
55,836 KB
testcase_26 AC 134 ms
55,816 KB
testcase_27 AC 132 ms
55,800 KB
testcase_28 AC 132 ms
55,792 KB
testcase_29 AC 135 ms
55,792 KB
testcase_30 AC 131 ms
55,556 KB
testcase_31 AC 134 ms
56,020 KB
testcase_32 AC 130 ms
55,848 KB
testcase_33 AC 129 ms
55,888 KB
testcase_34 AC 130 ms
55,916 KB
testcase_35 AC 129 ms
55,804 KB
testcase_36 AC 131 ms
54,068 KB
testcase_37 AC 130 ms
55,972 KB
testcase_38 AC 130 ms
55,856 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 132 ms
55,948 KB
testcase_43 AC 130 ms
56,104 KB
testcase_44 WA -
testcase_45 AC 134 ms
55,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		sc.close();

//		if (n == 1) {
//			System.out.println(m);
//			return;
//		}

		int p = m;
		long ans = m;
		for (int i = 1; i < n; i++) {
			if (p == 1) {
				ans += n - i;
				break;
			}
			if (p % 2 == 0) {
				p = p / 2;
			} else {
				p = p / 2 + 1;
			}
			ans += p;
		}
		System.out.println(ans);
	}
}
0