結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
![]() |
提出日時 | 2020-05-16 03:58:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,340 bytes |
コンパイル時間 | 1,072 ms |
コンパイル使用メモリ | 160,728 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-19 20:15:52 |
合計ジャッジ時間 | 3,710 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 68 WA * 54 |
ソースコード
/** * @FileName f.cpp * @Author kanpurin * @Created 2020.05.16 03:57:49 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { long double a, b, c; cin >> a >> b >> c; if (a != 0) { if (b * b - 4 * a * c > 0) { cout << 2 << endl; long double x, y; if (b >= 0) { x = (-b - sqrtl(b * b - 4 * a * c)) / (2 * a); y = -b / a - x; } else { x = (-b + sqrtl(b * b - 4 * a * c)) / (2 * a); y = -b / a - x; } if (x < y) { cout << fixed << setprecision(20) << x << endl; cout << fixed << setprecision(20) << y << endl; } else { cout << fixed << setprecision(20) << y << endl; cout << fixed << setprecision(20) << x << endl; } } else if (b * b - 4 * a * c == 0) { cout << 1 << endl; cout << fixed << setprecision(20) << -b / (2 * a) << endl; } else { cout << 0 << endl; } } else if (b != 0) { cout << 1 << endl; cout << fixed << setprecision(20) << -b / (2 * a) << endl; } else if (c != 0) { cout << 0 << endl; } else { cout << -1 << endl; } return 0; }