結果
問題 |
No.955 ax^2+bx+c=0
|
ユーザー |
![]() |
提出日時 | 2019-12-18 18:31:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,705 bytes |
コンパイル時間 | 955 ms |
コンパイル使用メモリ | 85,236 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-18 22:13:50 |
合計ジャッジ時間 | 3,423 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 122 |
ソースコード
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<bitset> #include<set> #include<map> #include<stack> #include<queue> #include<deque> #include<list> #include<iomanip> #include<cmath> #include<cstring> #include<functional> using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define INF 2e9 //#define MOD 1000000007 #define MOD 998244353 #define LINF (long long)4e18 #define jck 3.141592 using ll = long long; using Pi = pair<int,int>; using Pl = pair<ll,ll>; int main(){ cout << fixed << setprecision(15); ll a,b,c; cin >> a >> b >> c; if(a == 0 && b == 0 && c == 0){ cout << -1 << endl; return 0; } if(a == 0 && b == 0 && c != 0){ cout << 0 << endl; return 0; } if(a == 0 && b != 0){ cout << 1 << endl; cout << (double)(-c)/b << endl; return 0; } if(b*b-4*a*c == 0){ cout << 1 << endl; cout << (double)(-b)/(2*a) << endl; } else if(b*b-4*a*c < 0){ cout << 0 << endl; } else{ cout << 2 << endl; double ans1 = ((double)(-b)+sqrt(b*b-4*a*c))/(2*a); double ans2 = ((double)(-b)-sqrt(b*b-4*a*c))/(2*a); if(a > 0){ if(b >= 0){ ans1 = (double)c/(a*ans2); } else ans2 = (double)c/(a*ans1); cout << ans2 << endl; cout << ans1 << endl; } else{ if(b >= 0){ ans1 = (double)c/(a*ans2); } else ans2 = (double)c/(a*ans1); cout << ans1 << endl; cout << ans2 << endl; } } }