結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー |
![]() |
提出日時 | 2019-12-19 10:57:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 705 bytes |
コンパイル時間 | 1,584 ms |
コンパイル使用メモリ | 167,464 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 01:02:44 |
合計ジャッジ時間 | 3,706 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 108 WA * 14 |
ソースコード
#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 - sqrt(d)) / (2 * a); } else { x1 = (-b + sqrt(d)) / (2 * a); } x2 = c / a / x1; if(x1 > x2) swap(x1, x2); printf("%.15f\n", x1); printf("%.15f\n", x2); } return 0; }