結果

問題 No.1869 Doubling?
ユーザー ks2mks2m
提出日時 2022-03-11 22:11:32
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 443 bytes
コンパイル時間 1,892 ms
コンパイル使用メモリ 71,868 KB
実行使用メモリ 66,612 KB
最終ジャッジ日時 2023-10-14 07:20:48
合計ジャッジ時間 9,406 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,004 KB
testcase_01 AC 121 ms
55,640 KB
testcase_02 AC 123 ms
56,200 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 123 ms
56,172 KB
testcase_07 AC 119 ms
55,500 KB
testcase_08 AC 119 ms
56,372 KB
testcase_09 WA -
testcase_10 AC 119 ms
55,828 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 129 ms
56,152 KB
testcase_16 AC 130 ms
56,028 KB
testcase_17 AC 131 ms
55,820 KB
testcase_18 AC 132 ms
56,104 KB
testcase_19 AC 129 ms
56,424 KB
testcase_20 AC 130 ms
56,388 KB
testcase_21 AC 126 ms
55,708 KB
testcase_22 AC 134 ms
55,864 KB
testcase_23 AC 130 ms
55,892 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 120 ms
56,608 KB
testcase_34 AC 122 ms
55,972 KB
testcase_35 AC 121 ms
55,996 KB
testcase_36 AC 124 ms
56,416 KB
testcase_37 AC 122 ms
56,408 KB
testcase_38 AC 121 ms
55,724 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 RE -
testcase_43 RE -
testcase_44 WA -
testcase_45 AC 122 ms
55,624 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();

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