結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-12-30 16:34:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 893 bytes |
| コンパイル時間 | 1,753 ms |
| コンパイル使用メモリ | 193,104 KB |
| 最終ジャッジ日時 | 2025-01-17 08:35:16 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 93 WA * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
double a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b != 0) {
cout << 1 << endl;
cout << fixed << setprecision(12) << -c/b << endl;
} else {
if (c == 0)
cout << -1 << endl;
else
cout << 0 << endl;
}
} else {
double d = b*b - 4*a*c;
if (d < 0) {
cout << 0 << endl;
} else if (d == 0) {
cout << 1 << endl;
cout << fixed << setprecision(12) << -b/(2*a) << endl;
} else {
cout << 2 << endl;
double x1 = (-b + sqrt(d)) / (2 * a);
double x2 = (-b - sqrt(d)) / (2 * a);
cout << fixed << setprecision(12) << min(x1,x2) << endl;
cout << fixed << setprecision(12) << max(x1,x2) << endl;
}
}
return 0;
}