結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-18 11:02:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 777 bytes |
| コンパイル時間 | 616 ms |
| コンパイル使用メモリ | 73,960 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 00:37:43 |
| 合計ジャッジ時間 | 9,191 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 54 WA * 24 RE * 44 |
ソースコード
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cassert>
using namespace std;
typedef long double ld;
int main(){
cout << fixed << setprecision(15);
ld a, b, c;
cin >> a >> b >> c;
if(a == 0){
assert(a!=0);
if(b == 0){
cout << (c==0 ? -1 : 0) << endl;
}else{
cout << 1 << endl << -c/b << endl;
}
}else{
ld d = b*b-4*a*c;
if(d < 0){
cout << 0 << endl;
}else if(d == 0){
cout << 1 << endl << -b/a/2 << endl;
}else{
ld f = sqrt(d);
cout << 2 << endl;
ld x = (-b-f)/a/2, y = (-b+f)/a/2;
if(x > y) swap(x, y);
cout << x << endl << y << endl;
}
}
return 0;
}