結果

問題 No.40 多項式の割り算
ユーザー samplelpmas
提出日時 2017-02-01 16:47:17
言語 Java
(openjdk 23)
結果
AC  
実行時間 278 ms / 5,000 ms
コード長 782 bytes
コンパイル時間 2,227 ms
コンパイル使用メモリ 74,180 KB
実行使用メモリ 46,508 KB
最終ジャッジ日時 2024-12-24 02:19:06
合計ジャッジ時間 11,486 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    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; 3 <= i; i--) {

            a[i - 2] += a[i];
            a[i] = 0;

        }

        int degree = 0;

        for (int i = D; 0 <= i; i--) {

            if (a[i] != 0) {
                degree = i;
                break;
            }

        }

        System.out.println(degree);

        for (int i = 0; i <= degree; i++) {

            if (0 < i) {
                System.out.print(' ');
            }

            System.out.print(a[i]);

        }

    }

}
0