結果

問題 No.955 ax^2+bx+c=0
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-05-16 04:00:28
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,334 bytes
コンパイル時間 1,282 ms
コンパイル使用メモリ 161,140 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-19 20:18:58
合計ジャッジ時間 3,706 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 98 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	f.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.16 04:00:21
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    long double a, b, c;
    cin >> a >> b >> c;
    if (a != 0) {
        if (b * b - 4 * a * c > 0) {
            cout << 2 << endl;
            long double x, y;
            if (b >= 0) {
                x = (-b - sqrtl(b * b - 4 * a * c)) / (2 * a);
                y = -b / a - x;
            } else {
                x = (-b + sqrtl(b * b - 4 * a * c)) / (2 * a);
                y = -b / a - x;
            }
            if (x < y) {
                cout << fixed << setprecision(20) << x << endl;
                cout << fixed << setprecision(20) << y << endl;
            } else {
                cout << fixed << setprecision(20) << y << endl;
                cout << fixed << setprecision(20) << x << endl;
            }
        } else if (b * b - 4 * a * c == 0) {
            cout << 1 << endl;
            cout << fixed << setprecision(20) << -b / (2 * a) << endl;
        } else {
            cout << 0 << endl;
        }
    } else if (b != 0) {
        cout << 1 << endl;
        cout << fixed << setprecision(20) << -c / b << endl;
    } else if (c != 0) {
        cout << 0 << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}
0