結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
|
提出日時 | 2019-12-18 03:32:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,779 bytes |
コンパイル時間 | 671 ms |
コンパイル使用メモリ | 74,456 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 00:22:36 |
合計ジャッジ時間 | 3,069 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 85 WA * 37 |
ソースコード
#include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { long long a, b, c; cin >> a >> b >> c; cout << fixed << setprecision(60); if (a == 0LL) { if (b == 0LL) { if (c == 0LL) { cout << (-1) << endl; } else { cout << 0 << endl; } } else { cout << 1 << endl << (-(long double)c / (long double)b) << endl; } } else { if (b == 0LL) { if (c == 0LL) { cout << 1 << endl << 0 << endl; } else { long double e = -(long double)c / (long double)a; if (e < 0.0) { cout << 0 << endl; } else { long double x = sqrt(e); cout << 2 << endl << (-x) << endl << x << endl; } } } else { if (c == 0LL) { long double x = -(long double)b / (long double)a; cout << 2 << endl << min(x, (long double)0) << endl << max(x, (long double)0) << endl; } else { long long D = b * b - 4LL * a * c; if (D < 0LL) { cout << 0 << endl; } else if (D == 0LL) { cout << 1 << endl << (-(long double)b / (long double)a) << endl; } else if (D > 0LL) { long double y = (-(long double)b - sqrt((long double)D)) / (long double)(2LL*a); long double z = (-(long double)b + sqrt((long double)D)) / (long double)(2LL*a); cout << 2 << endl << min(y, z) << endl << max(y, z) << endl; } } } } return 0; }