#include <stdio.h> #include <math.h> #define MIN_ERR 1e-4 double a,b,c,d; double f(double x) { return a*x*x*x+b*x*x+c*x+d; } double find_sol(double min,double max) { if (max-min<MIN_ERR) return (min+max)/2; else { double f1,f2,f3; f1=f(min); f2=f((min+max)/2); f3=f(max); if (f2==0) return (min+max)/2; else if (f1*f2<0) return find_sol(min,(min+max)/2); else return find_sol((min+max)/2,max); } } main() { double x1,x2; scanf("%lf%lf%lf%lf",&a,&b,&c,&d); if (a<0) { a=-a; b=-b; c=-c; d=-d; } x1=(-2*b-sqrt(4*b*b-12*a*c))/(a*6); x2=(-2*b+sqrt(4*b*b-12*a*c))/(a*6); printf("%.2lf %.2lf %.2lf\n",find_sol(-101,x1),find_sol(x1,x2),find_sol(x2,101)); } /************************************************************** Problem: 1692 User: admin Language: C++ Result: Accepted Time:7 ms Memory:1144 kb ****************************************************************/