結果

問題 No.40 多項式の割り算
ユーザー Grenache
提出日時 2015-11-03 16:50:07
言語 Java
(openjdk 23)
結果
AC  
実行時間 253 ms / 5,000 ms
コード長 787 bytes
コンパイル時間 3,530 ms
コンパイル使用メモリ 77,600 KB
実行使用メモリ 57,736 KB
最終ジャッジ日時 2024-09-13 12:10:26
合計ジャッジ時間 11,650 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder40 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int d = sc.nextInt();
        int[] a = new int[d + 1];
        for (int i = 0; i <= d; i++) {
        	a[i] = sc.nextInt();
        }
        
        for (int i = d; i >= 3; i--) {
        	a[i - 2] -= -a[i];
        	a[i] = 0;
        }

        if (d > 1 && a[2] != 0) {
        	System.out.println("2");
        	System.out.printf("%d %d %d\n", a[0], a[1], a[2]);
        } else if (d > 0 && a[1] != 0) {
        	System.out.println("1");
        	System.out.printf("%d %d\n", a[0], a[1]);
        } else {
        	System.out.println("0");
        	System.out.printf("%d\n", a[0]);
        }

        sc.close();
    }
}
0