結果

問題 No.2609 Decreasing GCDs
ユーザー ks2mks2m
提出日時 2024-01-19 22:03:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 1,000 ms
コード長 701 bytes
コンパイル時間 2,450 ms
コンパイル使用メモリ 74,808 KB
実行使用メモリ 57,968 KB
最終ジャッジ日時 2024-01-19 22:03:32
合計ジャッジ時間 7,397 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
57,820 KB
testcase_01 AC 146 ms
57,968 KB
testcase_02 AC 137 ms
57,836 KB
testcase_03 AC 138 ms
57,704 KB
testcase_04 AC 136 ms
57,552 KB
testcase_05 AC 135 ms
57,780 KB
testcase_06 AC 150 ms
57,556 KB
testcase_07 AC 137 ms
57,852 KB
testcase_08 AC 135 ms
57,828 KB
testcase_09 AC 151 ms
57,648 KB
testcase_10 AC 137 ms
57,836 KB
testcase_11 AC 138 ms
57,560 KB
testcase_12 AC 137 ms
57,964 KB
testcase_13 AC 135 ms
57,568 KB
testcase_14 AC 135 ms
57,696 KB
testcase_15 AC 140 ms
57,560 KB
testcase_16 AC 145 ms
57,816 KB
testcase_17 AC 136 ms
57,588 KB
testcase_18 AC 136 ms
57,684 KB
testcase_19 AC 139 ms
57,624 KB
testcase_20 AC 146 ms
57,804 KB
testcase_21 AC 139 ms
57,824 KB
testcase_22 AC 135 ms
57,680 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();
		sc.close();

		int[] a = new int[n];
		a[0] = 1;
		for (int i = 1; i < n; i++) {
			a[i] = a[i - 1] * 2;
		}
		for (int i = n - 2; i >= 0; i--) {
			a[i] += a[i + 1];
		}

		StringBuilder sb = new StringBuilder();
		for (int i = n - 1; i >= 0; i--) {
			sb.append(a[i]).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());

//		for (int i = n - 2; i >= 0; i--) {
//			System.out.println(gcd(a[i + 1], a[i]));
//		}
	}

	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}
0