結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
東前頭十一枚目
|
| 提出日時 | 2019-12-19 10:59:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 729 bytes |
| コンパイル時間 | 1,691 ms |
| コンパイル使用メモリ | 167,376 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-18 22:15:29 |
| 合計ジャッジ時間 | 4,660 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 122 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t a, b, c; cin >> a >> b >> c;
if(a == 0) {
if(b == 0) {
if(c == 0) {
cout << -1 << '\n';
} else {
cout << 0 << '\n';
}
return 0;
}
cout << 1 << '\n';
printf("%.15f\n", (double)-c / b);
return 0;
}
int64_t d = b * b - 4 * a * c;
if(d < 0) {
cout << 0 << '\n';
} else if(d == 0) {
cout << 1 << '\n';
printf("%.15f\n", (double)-b / (2 * a));
} else {
cout << 2 << '\n';
double x1, x2;
if(b > 0) {
x1 = (-b * 1.0 - sqrt(d)) / (2.0 * a);
} else {
x1 = (-b * 1.0 + sqrt(d)) / (2.0 * a);
}
x2 = (double)c / a / x1;
if(x1 > x2) swap(x1, x2);
printf("%.15f\n", x1);
printf("%.15f\n", x2);
}
return 0;
}
東前頭十一枚目