游客 Signup | Login
中文 | En

1873 - C语言考试练习题_一元二次方程

解一元二次方程ax^2+bx+c=0的解。

Input

a,b,c的值。

Output

两个根X1和X2,其中X1>=X2。。

结果保留两位小数

Examples

Input

1 5 -2

Output

0.37 -5.37

Solution C++

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	double a,b,c;
	cin>>a>>b>>c;
	double dis=b*b-4*a*c;
	double p=-b/(2*a),q=sqrt(dis)/(2*a);
	printf("%.2lf %.2lf\n",p+q,p-q);
	return 0;
} 
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题