結果

問題 No.1179 Quadratic Equation
ユーザー umezo
提出日時 2020-08-21 23:20:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 192,872 KB
最終ジャッジ日時 2025-01-13 06:35:20
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
  double a, b, c,d;
  double x1, x2;

  cin>>a>>b>>c;
  
  d = b * b - 4 * a * c;
    if(d >=0){                   
      x1 = (fabs(b) + sqrt(d)) / (2.0 * a);
      if ( b >= 0.0 ) {
        x1 = -x1;
      }
      x2 = c / (a * x1);
      if(d==0) cout<<fixed<<setprecision(10)<<x1<<endl;
      else cout<<fixed<<setprecision(10)<<min(x1,x2)<<" "<<max(x1,x2)<<endl;
      }
      else{                                  
      cout<<"imaginary"<<endl;
    }

    return 0;
}
0