結果

問題 No.40 多項式の割り算
ユーザー rn4ru
提出日時 2016-04-14 06:06:54
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 568 bytes
コンパイル時間 2,261 ms
コンパイル使用メモリ 76,220 KB
実行使用メモリ 47,452 KB
最終ジャッジ日時 2024-10-04 08:19:51
合計ジャッジ時間 9,438 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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