結果

問題 No.955 ax^2+bx+c=0
ユーザー granddaifukugranddaifuku
提出日時 2020-03-18 20:46:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 916 bytes
コンパイル時間 1,719 ms
コンパイル使用メモリ 172,640 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 02:29:02
合計ジャッジ時間 5,132 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54 WA * 68
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(12);
    vector<ld> res;
    ll a, b, c, t;
    cin >> a >> b >> c;
    t = b * b - 4 * a * c;
    if (t < 0) {
        cout << 0 << endl;
        return 0;
    }
    if (t == 0) res.push_back(-b / (ld)(2 * a));
    if (t > 0) {
        res.push_back(((-b) + sqrt((ld)t)) / (ld)(2 * a));
        res.push_back(((-b) - sqrt((ld)t)) / (ld)(2 * a));
    }
    sort(res.begin(), res.end());
    cout << res.size() << endl;
    rep (i, res.size()) cout << res[i] << endl;
    
    return 0;
}

0