結果

問題 No.40 多項式の割り算
ユーザー htensai
提出日時 2020-02-14 10:41:17
言語 Java
(openjdk 23)
結果
AC  
実行時間 295 ms / 5,000 ms
コード長 668 bytes
コンパイル時間 2,485 ms
コンパイル使用メモリ 77,008 KB
実行使用メモリ 48,840 KB
最終ジャッジ日時 2024-10-06 07:45:02
合計ジャッジ時間 11,130 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int[] arr = new int[d + 1];
		for (int i = 0; i <= d; i++) {
		    arr[i] = sc.nextInt();
		}
		for (int i = d; i >= 3; i--) {
		    int x = arr[i];
		    arr[i - 2] += x;
		    arr[i] = 0;
		}
		if (d >= 2 && arr[2] != 0) {
		    System.out.println(2);
		    System.out.println(arr[0] + " " + arr[1] + " " + arr[2]);
		} else if (d >= 1 && arr[1] != 0) {
		    System.out.println(1);
		    System.out.println(arr[0] + " " + arr[1]);
		} else {
		    System.out.println(0);
		    System.out.println(arr[0]);
		}
   }
}
0