結果

問題 No.955 ax^2+bx+c=0
ユーザー square1001
提出日時 2020-01-30 20:20:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 690 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 70,912 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-16 03:50:17
合計ジャッジ時間 3,286 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 90 WA * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <iostream>
using namespace std;
int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	cout.precision(15);
	if (a == 0 && b == 0 && c == 0) {
		cout << -1 << endl;
	}
	else if (a == 0 && b == 0) {
		cout << 0 << endl;
	}
	else if (a == 0) {
		cout << 1 << endl;
		cout << fixed << -(long double)(c) / b << endl;
	}
	else {
		long long d = b * b - 4 * a * c;
		if (d < 0) {
			cout << 0 << endl;
		}
		else if (d == 0) {
			cout << 1 << endl;
			cout << -(long double)(b) / (2 * a) << endl;
		}
		else {
			cout << 2 << endl;
			cout << (-b - sqrt((long double)(d))) / (2 * a) << endl;
			cout << (-b + sqrt((long double)(d))) / (2 * a) << endl;
		}
	}
	return 0;
}
0