結果

問題 No.1869 Doubling?
ユーザー ks2m
提出日時 2022-03-11 22:11:32
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 443 bytes
コンパイル時間 2,818 ms
コンパイル使用メモリ 74,224 KB
実行使用メモリ 44,364 KB
最終ジャッジ日時 2024-09-16 02:28:48
合計ジャッジ時間 9,686 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 9 RE * 14
権限があれば一括ダウンロードができます

ソースコード

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