結果

問題 No.40 多項式の割り算
ユーザー bluemeganebluemegane
提出日時 2021-04-23 13:01:28
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,000 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 67,700 KB
実行使用メモリ 23,340 KB
最終ジャッジ日時 2023-09-17 10:55:16
合計ジャッジ時間 4,495 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 61 ms
22,752 KB
testcase_02 AC 60 ms
20,828 KB
testcase_03 AC 62 ms
20,684 KB
testcase_04 AC 69 ms
21,268 KB
testcase_05 AC 71 ms
23,220 KB
testcase_06 AC 70 ms
21,436 KB
testcase_07 AC 71 ms
21,444 KB
testcase_08 AC 69 ms
20,968 KB
testcase_09 AC 70 ms
23,340 KB
testcase_10 AC 71 ms
21,368 KB
testcase_11 AC 69 ms
21,208 KB
testcase_12 AC 70 ms
21,064 KB
testcase_13 AC 70 ms
21,332 KB
testcase_14 AC 71 ms
21,204 KB
testcase_15 AC 70 ms
23,188 KB
testcase_16 AC 71 ms
21,344 KB
testcase_17 AC 70 ms
23,056 KB
testcase_18 AC 70 ms
21,268 KB
testcase_19 AC 72 ms
21,360 KB
testcase_20 AC 70 ms
23,212 KB
testcase_21 AC 69 ms
21,036 KB
testcase_22 AC 68 ms
23,040 KB
testcase_23 AC 70 ms
21,220 KB
testcase_24 AC 70 ms
23,312 KB
testcase_25 AC 59 ms
20,896 KB
testcase_26 AC 61 ms
20,760 KB
testcase_27 AC 61 ms
22,788 KB
testcase_28 RE -
testcase_29 AC 61 ms
22,732 KB
testcase_30 AC 61 ms
20,912 KB
testcase_31 AC 61 ms
22,852 KB
testcase_32 RE -
testcase_33 AC 61 ms
20,784 KB
testcase_34 AC 62 ms
20,752 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];
        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