题面:
代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#define ll long long
#define llu unsigned ll
using namespace std;
const double eps=1e-8;
int n;
double a[20];
double mypow(double a,int b)
{
double ans=1;
while(b)
{
if(b&1) ans=ans*a;
a=a*a;
b>>=1;
}
return ans;
}
double fi(double x)
{
double ans=0;
for(int i=0;i<=n;i++)
ans+=a[i]*mypow(x,n-i);
return ans;
}
int main(void)
{
double l,r;
scanf("%d%lf%lf",&n,&l,&r);
for(int i=0;i<=n;i++)
scanf("%lf",&a[i]);
double m,mm;
while(r-l>eps)
{
m=(l+r)/2;
mm=(m+r)/2;
if(fi(m)>=fi(mm)) r=mm;
else l=m;
}
printf("%.5f\n",(l+r)/2);
return 0;
}