結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
|
提出日時 | 2020-03-18 20:50:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,095 bytes |
コンパイル時間 | 1,820 ms |
コンパイル使用メモリ | 173,616 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-14 02:29:32 |
合計ジャッジ時間 | 4,614 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 68 WA * 54 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (int)n; ++i) #define FOR(i, a, b) for(int i = a; i < (int)b; ++i) #define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i) typedef long long ll; typedef long double ld; const int Inf = 1e9; const double EPS = 1e-9; const int MOD = 1e9 + 7; int main() { cin.tie(nullptr); ios::sync_with_stdio(0); cout << fixed << setprecision(12); vector<ld> res; ll a, b, c, t; cin >> a >> b >> c; t = b * b - 4 * a * c; if (t < 0) { cout << 0 << endl; return 0; } if (a == 0) { if (b == 0 && c == 0) cout << -1 << endl; else if (b == 0 || c == 0) cout << 0 << endl; else cout << -1 << endl; return 0; } if (t == 0) res.push_back(-b / (ld)(2 * a)); if (t > 0) { res.push_back(((-b) + sqrt((ld)t)) / (ld)(2 * a)); res.push_back(((-b) - sqrt((ld)t)) / (ld)(2 * a)); } sort(res.begin(), res.end()); cout << res.size() << endl; rep (i, res.size()) cout << res[i] << endl; return 0; }