結果

問題 No.955 ax^2+bx+c=0
ユーザー risujiroh
提出日時 2019-12-18 00:03:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 839 bytes
コンパイル時間 1,296 ms
コンパイル使用メモリ 167,448 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 23:30:52
合計ジャッジ時間 3,557 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 89 WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long a, b, c;
  cin >> a >> b >> c;
  if (a == 0) {
    if (b == 0) {
      if (c == 0) {
        cout << -1 << '\n';
      } else {
        cout << 0 << '\n';
      }
    } else {
      cout << 1 << '\n';
      cout << fixed << setprecision(15) << (double)(-c) / b << '\n';
    }
  } else {
    if (b * b == 4 * a * c) {
      cout << 1 << '\n';
      cout << fixed << setprecision(15) << (double)(-b) / (2 * a) << '\n';
    } else if (b * b - 4 * a * c > 0) {
      double d = sqrt(b * b - 4 * a * c);
      cout << 2 << '\n';
      cout << fixed << setprecision(15) << (-b + d) / (2 * a) << '\n';
      cout << fixed << setprecision(15) << (-b - d) / (2 * a) << '\n';
    } else {
      cout << 0 << '\n';
    }
  }
}
0