結果

問題 No.955 ax^2+bx+c=0
コンテスト
ユーザー bluemegane
提出日時 2021-05-12 21:20:00
言語 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
結果
WA  
実行時間 -
コード長 1,213 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 912 ms
コンパイル使用メモリ 105,728 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2026-04-11 14:30:14
合計ジャッジ時間 5,836 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 75 WA * 47
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 static System.Math;
using System;

public class Hello
{
    public static long a, b, c;
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        a = long.Parse(line[0]);
        b = long.Parse(line[1]);
        c = long.Parse(line[2]);
        getAns();
    }
    static void getAns()
    {
        var ans = 0d;
        if (a == 0 && b == 0) { Console.WriteLine(-1); return; }
        if (a != 0 && b * b == 4 * a * c)
        {
            Console.WriteLine(1);
            ans = -b / 2d / a;
            Console.WriteLine(ans);
            return;
        }
        if (a != 0 && b * b > 4 * a * c)
        {
            Console.WriteLine(2);
            var t = Sqrt(b * b - 4d * a * c);
            ans = (-b - t) / 2d / a;
            Console.WriteLine(ans);
            ans = (-b + t) / 2d / a;
            Console.WriteLine(ans);
            return;
        }
        if (a != 0 && b * b < 4 * a * c)
        {
            Console.WriteLine(0);
            return;
        }
        if (a == 0 && b != 0)
        {
            Console.WriteLine(1);
            ans = -(double)c / b;
            Console.WriteLine(ans);
            return;
        }
    }
}
0