1 solutions
-
0
C++ :
#include<cstring> #include<cstdio> using namespace std; double ans[4]; double a,b,c,d; double f(double xt) { double s; s=xt*xt*xt+b*xt*xt+c*xt+d; return s; } int main() { scanf("%lf%lf%lf%lf",&a,&b,&c,&d); b/=a; c/=a; d/=a; double x1,x2; int p=0; for (int x=-10000;x<=10000;x++) { x1=(x-0.05)/100.0; x2=(x+0.05)/100.0; if (f(x/100.0)==0 || f(x1)*f(x2)<0) { p++; ans[p]=x/100.0; } if (p==3) break; } for (int i=1;i<=2;i++) for (int j=2;j<=3;j++) if (ans[i]>ans[j]) { double t=ans[i];ans[i]=ans[j];ans[j]=t; } for (int i=1;i<=p-1;i++) printf("%.2lf ",ans[i]); printf("%0.2lf\n",ans[p]); return 0; }
- 1
Information
- ID
- 777
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By