結果
| 問題 |
No.1179 Quadratic Equation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-25 15:05:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 538 bytes |
| コンパイル時間 | 845 ms |
| コンパイル使用メモリ | 88,684 KB |
| 最終ジャッジ日時 | 2025-01-13 14:21:55 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 |
ソースコード
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
double a, b, c;
cin >> a >> b >> c;
double d = b*b-4*a*c;
cout << fixed << setprecision(12);
if(d < 0){
cout << "imaginary" << endl;
}else if(d == 0){
cout << -b/2/a << endl;
}else{
d = sqrt(d);
double y, z;
if(-b < 0) y = (-b-d)/2/a;
else y = (-b+d)/2/a;
z = c/a/y;
if(y > z) swap(y, z);
cout << y << " " << z << endl;
}
return 0;
}