結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
yakki
|
| 提出日時 | 2019-12-18 13:02:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,688 bytes |
| コンパイル時間 | 733 ms |
| コンパイル使用メモリ | 87,132 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 00:41:49 |
| 合計ジャッジ時間 | 2,969 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 90 WA * 32 |
ソースコード
#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 && b >= 0){
cout << ans1 << endl;
cout << ans2 << endl;
}
else if(a < 0 && b < 0){
cout << ans2 << endl;
cout << ans1 << endl;
}
else if(a > 0 && b >= 0){
cout << ans2 << endl;
cout << ans1 << endl;
}
else{
cout << ans1 << endl;
cout << ans2 << endl;
}
}
}
yakki