#include <stdio.h> #include <math.h> #define EPSILON 1e-7 double bisection(int p, int q, double (*func)(int, int, double)); double f(int p, int q, double x); int main() { int p; int q; scanf("%d%d", &p, &q); printf("%.4lf ", bisection(p, q, f)); return 0; } double bisection(int p, int q, double (*func)(int, int, double)) { double x1 = -20; double x2 = 20; double x = 0; while(fabs((*func)(p,q,x))>EPSILON) { x = (x1+x2)/2.0; double fx1 = (*func)(p,q,x1); double fx = (*func)(p,q,x); if(fx*fx1>0) {x1 = x;} else {x2 = x;} } return x; } double f(int p, int q, double x) { return p * x + q; }