結果

問題 No.955 ax^2+bx+c=0
ユーザー t33f
提出日時 2019-12-18 09:15:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 671 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 75,988 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 00:35:04
合計ジャッジ時間 3,504 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 59 WA * 63
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
    long long a, b, c; cin >> a >> b >> c;
    cout << setprecision(16);
    if (a == 0) {
        if (b == 0) {
            if (c == 0) cout << "-1\n";
            else cout << "0\n";
        } else {
            cout << (double)b/c << endl;
        }
    } else {
        long long d = b * b - 4 * a * c;
        if (d == 0) {
            cout << 1 << endl << -b/2.0/a << endl;
        } else if (d < 0) {
            cout << "0\n";
        } else {
            double r = sqrt(d);
            cout << 2 << endl << (-b-r)/2.0/a << endl << (-b+r)/2.0/a << endl;
        }
    }
}
0