結果

問題 No.1179 Quadratic Equation
ユーザー eve__fuyuki
提出日時 2024-05-10 20:19:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 194,288 KB
最終ジャッジ日時 2025-02-21 12:11:03
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
int main() {
    fast_io();
    int a, b, c;
    cin >> a >> b >> c;
    if (a < 0) {
        a = -a;
        b = -b;
        c = -c;
    }
    int d = b * b - 4 * a * c;
    cout << setprecision(16) << fixed;
    if (d < 0) {
        cout << "imaginary" << endl;
    } else if (d == 0) {
        cout << -b / (2.0 * a) << endl;
    } else {
        cout << (-b - sqrt(d)) / (2.0 * a) << " " << (-b + sqrt(d)) / (2.0 * a)
             << endl;
    }
}
0