-
Notifications
You must be signed in to change notification settings - Fork 0
/
cf_Eduation.cpp
57 lines (52 loc) · 1.16 KB
/
cf_Eduation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c,e,f;
cin>>a>>b>>c;
double d;
d=b*b-4*a*c;
if(a==0 and b==0 and c==0) cout<<-1<<endl;
else if(a==0 and b!=0 and c!=0)
{
cout<<1<<endl;
printf("%.7lf\n",-c/b);
}
else if(a==0 and c==0 and b!=0)
{
cout<<1<<endl;
cout<<0.00000<<endl;
}
else if(a==0 and b==0 and c!=0)
{
cout<<0<<endl;
}
else if(d>=0)
{
if(d==0)
{
cout<<1<<endl;
cout<<-b/(2*a)<<setprecision(5)<<endl;;
printf("%.7lf\n",-b/(2*a));
}
else if(d>0)
{
e=(-b+sqrt(d))/(2*a);
f=(-b-sqrt(d))/(2*a);
if(e>f)
{
cout<<2<<endl;
cout<<f<<setprecision(5);
printf("%.7lf\n",f);
printf("%.7lf\n",e);
}
else if(e<f)
{
cout<<2<<endl;
printf("%.7lf\n",e);
printf("%.7lf\n",f);
}
}
}
else cout<<0<<endl;
}