Returns the root of the equation using the bipartite method.
/** Hdu-2199 can you solve the equatino * Mike-W * 2012-4-17 **/# include <stdio. h> # include <stdlib. h> # include <string. h> # include <math. h> # define EPS (1e-6) # define ndisp_x0000x2const int CO [10] = {8, 7, 2, 3, 6}; double Foo (Double X) {double X0 = Co [0]; int I; for (I = 0; I <4; I ++) X0 = x * x0 + CO [I + 1]; return x0;} double solve (Double Y) {double X1 = 0.0, X2 = 100.0, mid; double Y1 = Foo (X1), y2 = Foo (X2); While (FABS (y1-y2)> EPS) {# ifdef di Sp_xforwarx2printf ("x1, x2 = % lf, % lf \ n", x1, x2); printf ("Y1, y2 = % lf, % lf \ n", Y1, y2); # endifmid = (X1 + x2)/2; If (FOO (MID)> Y) y2 = Foo (x2 = mid ); elsey1 = Foo (x1 = mid);} return x1;} int main (void) {int t; double min_v = (double) Foo (0); double max_v = (double) foo (100); Double Y; scanf ("% d", & T); While (t --> 0) {scanf ("% lf", & Y ); if (Y> max_v | Y <min_v) printf ("no solution! \ N "); elseprintf (" %. 4lf \ n ", solve (y);} return 0 ;}