結果

問題 No.40 多項式の割り算
ユーザー rn4ru
提出日時 2016-04-14 06:08:03
言語 Java
(openjdk 23)
結果
AC  
実行時間 236 ms / 5,000 ms
コード長 570 bytes
コンパイル時間 1,920 ms
コンパイル使用メモリ 76,372 KB
実行使用メモリ 58,756 KB
最終ジャッジ日時 2024-10-04 08:20:57
合計ジャッジ時間 9,494 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int D = scanner.nextInt();
		int[] a = new int[D + 1];
		for (int i = 0; i < D + 1; i++) {
			a[i] = scanner.nextInt();
		}

		for (int i = D; i >= 3; i--) {
			a[i - 2] += a[i];
			a[i] = 0;
		}

		int ans = 0;
		if (D >= 2 && a[2] != 0) {
			ans = 2;
		} else if (D >= 1 && a[1] != 0) {
			ans = 1;
		}
		System.out.println(ans);
		for (int i = 0; i <= ans; i++) {
			System.out.print(a[i] + " ");
		}
		System.out.println();
	}

}
0