結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
le_panda_noir
|
| 提出日時 | 2020-02-20 21:09:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 952 bytes |
| コンパイル時間 | 794 ms |
| コンパイル使用メモリ | 90,220 KB |
| 最終ジャッジ日時 | 2025-01-09 01:11:00 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 108 WA * 14 |
ソースコード
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;
int main() {
ll a, b, c;
cin >> a >> b >> c;
if (a < 0) {
a *= -1; b *= -1; c *= -1;
}
if (a == b && b == c && c == 0) {
cout << -1 << endl;
return 0;
}
cout << fixed << setprecision(20);
if (a == 0) {
if (b == 0) {
cout << 0 << endl;
return 0;
}
cout << 1 << endl;
cout << (double)-c / b << endl;
return 0;
}
ll D = b * b - 4 * a * c;
if (D < 0) {
cout << 0 << endl;
return 0;
}
if (D == 0) {
cout << 1 << endl;
cout << (double)(-b) / (2 * a) << endl;
return 0;
}
if (b > 0) {
cout << 2 << endl;
double x1 = (-b - sqrt(D)) / (2 * a);
cout << x1 << endl;
cout << c / a / x1 << endl;
} else {
cout << 2 << endl;
double x1 = (-b + sqrt(D)) / (2 * a);
cout << c / a / x1 << endl;
cout << x1 << endl;
}
return 0;
}
le_panda_noir