結果

問題 No.40 多項式の割り算
ユーザー bluemeganebluemegane
提出日時 2021-04-23 13:13:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 71 ms / 5,000 ms
コード長 1,155 bytes
コンパイル時間 1,046 ms
コンパイル使用メモリ 63,620 KB
実行使用メモリ 23,316 KB
最終ジャッジ日時 2023-09-17 10:55:57
合計ジャッジ時間 4,736 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
20,628 KB
testcase_01 AC 59 ms
22,776 KB
testcase_02 AC 60 ms
20,836 KB
testcase_03 AC 60 ms
22,612 KB
testcase_04 AC 69 ms
19,052 KB
testcase_05 AC 70 ms
21,200 KB
testcase_06 AC 69 ms
21,276 KB
testcase_07 AC 70 ms
21,152 KB
testcase_08 AC 68 ms
20,876 KB
testcase_09 AC 69 ms
21,128 KB
testcase_10 AC 69 ms
21,300 KB
testcase_11 AC 70 ms
23,124 KB
testcase_12 AC 69 ms
20,948 KB
testcase_13 AC 69 ms
23,316 KB
testcase_14 AC 70 ms
21,152 KB
testcase_15 AC 69 ms
21,048 KB
testcase_16 AC 71 ms
21,120 KB
testcase_17 AC 69 ms
20,932 KB
testcase_18 AC 70 ms
21,220 KB
testcase_19 AC 70 ms
21,408 KB
testcase_20 AC 69 ms
19,056 KB
testcase_21 AC 69 ms
23,072 KB
testcase_22 AC 68 ms
20,812 KB
testcase_23 AC 68 ms
21,104 KB
testcase_24 AC 70 ms
21,176 KB
testcase_25 AC 59 ms
20,748 KB
testcase_26 AC 60 ms
20,776 KB
testcase_27 AC 62 ms
22,776 KB
testcase_28 AC 60 ms
22,692 KB
testcase_29 AC 60 ms
20,736 KB
testcase_30 AC 59 ms
18,612 KB
testcase_31 AC 60 ms
20,900 KB
testcase_32 AC 61 ms
20,568 KB
testcase_33 AC 60 ms
20,792 KB
testcase_34 AC 60 ms
20,828 KB
権限があれば一括ダウンロードができます

ソースコード

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];
        if (n == 1) { t[2] = a[0]; goto next; }
        var imax = a.Length;
        if (imax > 4) imax = 4;
        for (int i = 0; i < imax ; i++) t[i] = a[i];
        if (imax <= 3) goto next;
        var b = new int[] { 1, 0, -1, 0 };
         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++;
        }
    next:;
        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