結果
| 問題 | 
                            No.955 ax^2+bx+c=0
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hipopo
                         | 
                    
| 提出日時 | 2020-01-08 18:35:23 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 21 ms / 2,000 ms | 
| コード長 | 836 bytes | 
| コンパイル時間 | 2,118 ms | 
| コンパイル使用メモリ | 195,160 KB | 
| 最終ジャッジ日時 | 2025-01-08 16:57:45 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 122 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == 0) {
        if (b == 0) {
            if (c == 0) printf("-1\n");
            else printf("0\n");
        }
        else printf("1\n%.15f\n", (double)-c / b);
    }
    else {
        ll d = b * b - 4 * a * c;
        if (d < 0) printf("0\n");
        else if (d == 0) printf("1\n%.15f\n", (double)-b / (2 * a));
        else {
            long double s1;
            if ((0 < b) ^ (0 < d)) s1 = (-b + sqrt((long double)d)) / (2 * a);
            else s1 = (-b - sqrt((long double)d)) / (2 * a);
            long double s2 = c / (s1 * a);
            cout << 2 << endl;
            cout << fixed << setprecision(15) << min(s1, s2) << endl;
            cout << max(s1, s2) << endl;
        }
    }
}
            
            
            
        
            
hipopo