結果

問題 No.955 ax^2+bx+c=0
コンテスト
ユーザー hipopo
提出日時 2020-01-08 18:29:01
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 709 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,204 ms
コンパイル使用メモリ 211,428 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2026-10-25 04:33:39
合計ジャッジ時間 6,528 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 107 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    if (a == 0) {
        if (b == 0) {
            if (c == 0) printf("-1\n");
            else printf("0\n");
        }
        else printf("1\n%.15f\n", (double)-c / b);
    }
    else {
        ll d = b * b - 4 * a * c;
        if (d < 0) printf("0\n");
        else if (d == 0) printf("1\n%.15f\n", (double)-b / (2 * a));
        else {
            double s1;
            if (0 < b) s1 = (-b - sqrt(d)) / 2 * a;
            else s1 = (-b + sqrt(d)) / 2 * a;
            double s2 = c / (s1 * a);
            printf("2\n%.15f\n%.15f\n", min(s1, s2), max(s1, s2));
        }
    }
}
0