結果

問題 No.40 多項式の割り算
ユーザー bluemegane
提出日時 2021-04-23 13:01:28
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,000 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 108,320 KB
実行使用メモリ 26,852 KB
最終ジャッジ日時 2024-07-04 07:00:51
合計ジャッジ時間 3,414 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29 RE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        n++;
        Array.Reverse(a);
        var t = new int[4];
        for (int i = 0; i < 4; i++) t[i] = a[i];
        var b = new int[] { 1, 0, -1, 0 };
        var imax = n - 3;
        var s = a[0];
        var p = 0;
        for (int i = 0; i < imax; i++)
        {
            for (int j = 1; j < 4; j++)
                t[j - 1] = t[j] - b[j] * s;
            if (4 + p < n) t[3] = a[4 + p];
            s = t[0];
            p++;
        }
        if (t[0] == 0)
        {
            if (t[1] == 0) Console.WriteLine("0\n{0}", t[2]);
            else Console.WriteLine("1\n{0} {1}", t[2], t[1]);
        }
        else Console.WriteLine("2\n{0} {1} {2}", t[2], t[1], t[0]);
    }
}
0