結果

問題 No.955 ax^2+bx+c=0
ユーザー ianCK
提出日時 2019-12-18 03:31:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 688 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 49,280 KB
最終ジャッジ日時 2025-01-08 12:15:37
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 98 WA * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%lld%lld%lld", &a, &b, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <math.h>
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 {
		if (a < 0) {
			a = -a;
			b = -b;
			c = -c;
		}
		long double ta(a), tb(b), tc(c);
		if (b * b - 4 * a * c > 0) printf("2\n%.20lf\n%.20lf\n", (double) ((-tb - sqrtl(tb * tb - 4 * ta * tc))/ (ta * 2)), (double) ((-tb + sqrtl(tb * tb - 4 * ta * tc))/ (ta * 2)));
		else if (b * b - 4 * a * c < 0) printf("0\n");
		else printf("1\n%.20lf\n", (double) (-tb / (ta * 2)));
	}
	
}
0