結果

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

ソースコード

diff #

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

int main() {
  long double a, b, c;
  cin >> a >> b >> c;
  long double d = b * b - 4 * a * c;
  if (d < 0) {
    cout << "imaginary" << "\n", 0;
  } else if (d == 0) {
    cout << fixed << setprecision(4) << (-b / (2 * a)) << "\n";
  } else {
    long double x = ((-b + sqrt(d)) / (2 * a));
    long double y = ((-b - sqrt(d)) / (2 * a));
    if (x > y) swap(x, y);
    cout << fixed << setprecision(4) << x << " ";
    cout << fixed << setprecision(4) << y << "\n";
  }
}
0