結果

問題 No.40 多項式の割り算
コンテスト
ユーザー bluemegane
提出日時 2021-04-23 07:51:47
言語 C#(csc)
(csc 3.9.0)
コンパイル:
csc -langversion:latest -unsafe -warn:0 -o+ /r:System.Numerics.dll _filename_ -out:a.exe
実行:
/usr/bin/mono a.exe
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 787 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 651 ms
コンパイル使用メモリ 105,856 KB
実行使用メモリ 20,352 KB
最終ジャッジ日時 2026-03-25 15:02:55
合計ジャッジ時間 2,349 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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.

ソースコード

diff #
raw source code

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);
    }
}
0