結果
| 問題 | No.40 多項式の割り算 | 
| コンテスト | |
| ユーザー |  bluemegane | 
| 提出日時 | 2021-04-23 07:51:47 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 35 ms / 5,000 ms | 
| コード長 | 787 bytes | 
| コンパイル時間 | 2,588 ms | 
| コンパイル使用メモリ | 104,960 KB | 
| 実行使用メモリ | 20,096 KB | 
| 最終ジャッジ日時 | 2024-07-04 06:55:14 | 
| 合計ジャッジ時間 | 3,387 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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.Linq;
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)
    {
        var c = a[0];
        var gp1 = a.Sum();
        var gp2 = c;
        for (int i = 1; i <= n; i++)
            gp2 += i % 2 == 0 ? a[i] : -a[i];
        var ans2 = (gp1 + gp2) / 2 - c;
        var ans1 = (gp1 - gp2) / 2;
        if (ans2 == 0)
        {
            if (ans1 == 0) Console.WriteLine("0\n{0}", c);
            else Console.WriteLine("1\n{0} {1}", c, ans1);
        }
        else Console.WriteLine("2\n{0} {1} {2}", c, ans1, ans2);
    }
}
            
            
            
        