結果
| 問題 | 
                            No.955 ax^2+bx+c=0
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-06-04 22:57:10 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 969 bytes | 
| コンパイル時間 | 1,500 ms | 
| コンパイル使用メモリ | 166,964 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-30 18:20:02 | 
| 合計ジャッジ時間 | 4,786 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 2 | 
| other | AC * 24 WA * 98 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
void solve(ld a, ld b, ld c)
{
    // 判別式
    ld D = b*b - 4.0L*a*c;
    cout << fixed << setprecision(10);
    if(a==0 && b == 0 && c==0)
    {
        cout << "-1\n";
    }
    else if((a==0 && b==0) || D<0)
    {
        cout << "0\n";
    }
    else if(a==0)
    {
        // x = -c/b | a==0
        cout << "1 " << -c/b << '\n';
    }
    else if(D==0)
    {
        // x = -b / 2a
        cout << "1 " << -b/(2.0L*a) << '\n';
    }
    else
    {
        ld x1 = (-b + sqrt(D)) / (2.0L * a);
        ld x2 = (-b - sqrt(D)) / (2.0L * a);
        cout << "2 " << min(x1, x2) << ' ' << max(x1, x2) << '\n';
    }
    
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    solve(a, b, c);
    return 0;
}