結果

問題 No.955 ax^2+bx+c=0
ユーザー totori_nyaatotori_nyaa
提出日時 2020-02-28 02:23:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 1,487 ms
コンパイル使用メモリ 168,624 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-13 16:17:08
合計ジャッジ時間 3,973 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 52 WA * 70
権限があれば一括ダウンロードができます

ソースコード

diff #

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


bool chmax(int &a,int b){
    if(a<b){
        a = b;
        return 1;
    }
    return 0;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    
    int a,b,c;
    cin>>a>>b>>c;
    if(a==0 && b==0){
        if(c)cout << 0 << endl;
        else cout << -1 << endl;
        return 0;
    }
    if(a==0){
        cout << 1 << endl;
        cout << (double)(-c/b) << endl;
        return 0;
    }
    double ans1,ans2;
    if(b*b == 4*a*c){
        cout << 1 << endl;
        double ans = (double)(-b / (2.0*a));
        cout << ans << endl;
        return 0;
    }
    cout << 2 << endl;
    ans1 = (double)( -b + sqrt(b*b - 4*a*c));
    ans2 = (double)( -b - sqrt(b*b - 4*a*c));
    ans1 /= (double)2.0*a;
    ans2 /= (double)2.0*a;
    cout << ans2 << endl;
    cout << ans1 << endl;
    return 0;

}
0