結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-18 03:38:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,846 bytes |
| コンパイル時間 | 654 ms |
| コンパイル使用メモリ | 74,700 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 00:23:32 |
| 合計ジャッジ時間 | 2,931 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 98 WA * 24 |
ソースコード
// 答え分からん・・・サンプル2のやつだけ直した
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
long long a, b, c; cin >> a >> b >> c;
cout << 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)(2LL*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;
}