洛谷---三分模板--P3382
#include<bits/stdc++.h>
using namespace std;
#define Acode ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
typedef long long ll;
double eps = 1e-6;
const int N = 100;
double a[N];
int n;
double f(double mid)
{
double res = 0;
double temp = 1;
for (int i = n+1; i >=1; i--)
{
res += temp * a[i];
temp *= mid;
}
return res;
}
int main()
{
Acode;
cin >> n;
double l, r;
cin >> l >> r;
for (int i = 1; i <= n + 1; i++)
{
cin >> a[i];
}
while (fabs(r - l) > eps)
{
double mid1 = l + (r - l) / 3;
double mid2 = r - (r - l) / 3;
if (f(mid1) < f(mid2))
{
l = mid1;
}
else
{
r = mid2;
}
}
cout << l<< '\n';
return 0;
}