結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー |
![]() |
提出日時 | 2020-04-26 12:33:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,417 bytes |
コンパイル時間 | 1,829 ms |
コンパイル使用メモリ | 169,860 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 20:34:50 |
合計ジャッジ時間 | 4,736 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 54 WA * 68 |
ソースコード
// #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P>IP; typedef vector<ll> V; typedef vector<V> V2; typedef vector<vector<P> > G; void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));} void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);} #define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++) #define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++) #define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--) #define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--) template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}} template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}} const ll INF = 1145141919; const ll MOD = 1000000007; const ll NUM = 101010; int main(){ ll a, b, c; cin >> a >> b >> c; if(a == 0 && b == 0 && c == 0){ cout << -1 << endl; return 0; } if(b * b - 4 * a * c < 0){ cout << 0 << endl; return 0; } if(b * b - 4 * a * c == 0){ cout << 1 << endl; double ans = -b / ((double)2.0 * a); printf("%.20f\n", ans); return 0; } cout << 2 << endl; double d = sqrt(b * b - 4 * a * c); double x1 = (-b + d) / ((double)2.0 * a); double x2 = (-b - d) / ((double)2.0 * a); printf("%.20f\n", min(x1, x2)); printf("%.20f\n", max(x1, x2)); return 0; }