結果

問題 No.955 ax^2+bx+c=0
コンテスト
ユーザー ianCK
提出日時 2019-12-18 03:49:56
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 965 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 550 ms
コンパイル使用メモリ 86,264 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-28 14:38:55
合計ジャッジ時間 2,748 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 98 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <iomanip>
using namespace std;
int main() {
	long long int a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	if (a == 0) {
		if (b == 0) {
			if (c == 0) printf("-1\n");
			else printf("0\n");
		}
		else printf("1\n%.20lf\n", (double)((long double)c / (long double) -b));
	}
	else {
		long double ta(a), tb(b), tc(c), d, sa, sb;
		d = b * b - 4 * a * c;
		d = sqrtl(d);
		
		if (b * b - 4 * a * c > 0) {
			sa = (-tb + d) / ta / 2; 
			sb = (-tb - d) / ta / 2; 
			if (sa < sb) {
				cout << 2 << '\n';
				cout << setprecision(80) << sa << '\n';
				cout << setprecision(80) << sb << '\n';
			}
			else {
				cout << 2 << '\n';
				cout << setprecision(80) << sb << '\n';
				cout << setprecision(80) << sa << '\n';
			}
		}
		else if (b * b - 4 * a * c < 0) printf("0\n");
		else printf("1\n%.20lf\n", (double) (-tb / (ta * 2)));
		
	}
	
}
0