結果

問題 No.955 ax^2+bx+c=0
ユーザー hiro71687k
提出日時 2023-04-16 11:39:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,123 bytes
コンパイル時間 3,955 ms
コンパイル使用メモリ 252,300 KB
最終ジャッジ日時 2025-02-12 09:07:52
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43 WA * 35 TLE * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=1444999999;
ll mod=1000000007;
int main(){
    ld a,b,c;
    cin >> a >> b >> c;
    if (b*b-4*a*c>0)
    {
        cout << 2 << endl;
        ld left=-inf,right=-(b/(2.0*a));
        while (right-left>0.0000000000001)
        {
            ld mid=(right+left)/2.0;
            if (a*mid*mid+b*mid+c>0)
            {
                left=mid;
            }else{
                right=mid;
            }
        }
        cout << setprecision(100) << left << endl;
        left=-(b/(2.0*a)),right=inf;
        while (right-left>0.0000000000001)
        {
            ld mid=(right+left)/2.0;
            if (a*mid*mid+b*mid+c>0)
            {
                right=mid;
            }else{
                left=mid;
            }
        }
        cout << setprecision(100) << left << endl;
    }else if (b*b-4*a*c==0)
    {
        cout << 1 << endl;
        cout << setprecision(100) << -(b/(2.0*a)) << endl;
    }else{
        cout << 0 << endl;
    }
}
0