結果
問題 |
No.40 多項式の割り算
|
ユーザー |
![]() |
提出日時 | 2021-04-23 13:08:11 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,107 bytes |
コンパイル時間 | 1,006 ms |
コンパイル使用メモリ | 111,184 KB |
実行使用メモリ | 26,672 KB |
最終ジャッジ日時 | 2024-07-04 07:00:55 |
合計ジャッジ時間 | 3,308 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 WA * 1 |
コンパイルメッセージ
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]; 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]); } }