#include <iostream>
#include <iomanip>
#include <cmath>
using namespace Std;
Class poly{
Public
Double C;
int e;
Poly*next;
};
Poly*input ();
Double f (poly*head,double x);
Double root (poly*head,double A, double b);
int main () {
Poly*head;
Double A, B;
Head = input ();
Cin >> a >> b;
cout << setiosflags (ios::fixed) << setprecision (3);
cout << Root (head, a, b) << Endl;
return 0;
}
Poly*input () {
/* Enter the items of the polynomial, return the head pointer */
Poly*p = new Poly;
Poly*head = p, *p1 = p;
while (Cin >> p->c >> p->e) {
P1 = p;
char ch = getchar ();
p = new Poly;
p1->next=p;
if (ch = = ' \ n ')/* encounters a space jump input */
Break
}
Delete p;
P1->next = NULL;
return head;
}
Double f (Poly*head, double x) {
/* Any number x to get the value of the expression */
Double sum = 0.0;
while (head) {
Sum + = Head->c*pow (x, head->e);
Head = head->next;
}
return sum;
}
Double root (Poly*head, double A, double b) {
/* Find root by dichotomy * *
Double X;
while (b-a>0.001) {
x = (A + b)/2;
if (ABS (f (head,x)) < 0.001)
return x;
else if (f (head,a) *f (head,x) < 0)
b = x;
Else
A = x;
}
return A;
}
The realization of the root by the binomial method in the chain list