結果

問題 No.1179 Quadratic Equation
ユーザー pengin_2000pengin_2000
提出日時 2022-10-30 16:02:53
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 545 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 28,488 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 13:28:20
合計ジャッジ時間 2,055 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 0 ms
4,376 KB
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
double sqrt(double a)
{
	double min, mid, max;
	min = 0;
	for (max = 1; max * max < a; max *= 2);
	int i;
	for (i = 0; i < 100; i++)
	{
		mid = (max + min) / 2;
		if (mid * mid < a)
			min = mid;
		else
			max = mid;
	}
	return max;
}
int main()
{
	int a, b, c;
	scanf("%d %d%d", &a, &b, &c);
	int d = b * b - 4 * a * c;
	if (d < 0)
		printf("imaginary\n");
	else if (d == 0)
		printf("%.20lf\n", -b / 2.0 / a);
	else
		printf("%.20lf %.20lf\n", (-b - sqrt((double)d)) / 2.0 / a, (-b + sqrt((double)d)) / 2.0 / a);
	return 0;
}
0