結果

問題 No.40 多項式の割り算
ユーザー tenten
提出日時 2020-11-17 09:06:40
言語 Java
(openjdk 23)
結果
AC  
実行時間 299 ms / 5,000 ms
コード長 790 bytes
コンパイル時間 2,495 ms
コンパイル使用メモリ 76,416 KB
実行使用メモリ 60,300 KB
最終ジャッジ日時 2024-07-23 01:55:44
合計ジャッジ時間 11,650 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 n = sc.nextInt();
        int[] arr = new int[Math.max(3, n + 1)];
        for (int i = 0; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        for (int i = n; i >= 3; i--) {
            arr[i - 2] += arr[i];
        }
        if (arr[2] == 0) {
            if (arr[1] == 0) {
                System.out.println(0);
                System.out.println(arr[0]);
            } else {
                System.out.println(1);
                System.out.println(arr[0] + " " + arr[1]);
            }
        } else {
            System.out.println(2);
            System.out.println(arr[0] + " " + arr[1] + " " + arr[2]);
        }
    }
}
0