結果
問題 | No.40 多項式の割り算 |
ユーザー |
![]() |
提出日時 | 2021-04-23 13:13:47 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 30 ms / 5,000 ms |
コード長 | 1,155 bytes |
コンパイル時間 | 2,277 ms |
コンパイル使用メモリ | 103,808 KB |
実行使用メモリ | 19,072 KB |
最終ジャッジ日時 | 2024-07-04 07:01:19 |
合計ジャッジ時間 | 3,620 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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]);}}