結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
yuruhiya
|
| 提出日時 | 2019-12-21 22:43:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 824 bytes |
| コンパイル時間 | 2,370 ms |
| コンパイル使用メモリ | 193,304 KB |
| 最終ジャッジ日時 | 2025-01-08 13:48:31 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 98 WA * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
cin >> a >> b >> c;
long double A = a, B = b, C = c;
cout << fixed << setprecision(18);
if (a == 0 && b == 0 && c == 0) {
cout << -1 << endl;
} else if (a == 0 && b == 0) {
cout << 0 << endl;
} else if (a == 0) {
cout << 1 << endl;
cout << -(C / B) << endl;
} else {
long long D = b * b - 4 * a * c;
if (D < 0) {
cout << 0 << endl;
} else if (D == 0) {
cout << 1 << endl;
cout << -B / (2 * A) << endl;
} else {
cout << 2 << endl;
long double ans1 = (-B + sqrt(static_cast<long double>(D))) / (2 * A);
long double ans2 = (-B - sqrt(static_cast<long double>(D))) / (2 * A);
cout << min(ans1, ans2) << endl;
cout << max(ans1, ans2) << endl;
}
}
}
yuruhiya