题目链接 https://www.luogu.com.cn/problem/P3382
只过了样例 其他全wa了
奉上一组正确的测试数据
输入
11 0.25772881 3.23473312
6.46168846 106.20415243 555.00937049 95.77925452 -8932.85681491 -28032.97480712 -4981.77106419 112724.58269050 179518.01283243 44583.62090007 -66153.73991757 -21.09453684
输出
1.75481664201934
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define memset(a,b) memset(a,b,sizeof(a))
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1.0);
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
//10 61109567 21 22219134 0x3f
int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
int n,a[20];
double f(double x)
{
double ans=0;
for(int i=n;i>=0;i--)
ans+=a[i]*pow(x,i);
return ans;
}
int main()
{
ios;double l,r;cin>>n>>l>>r;
for(int i=n;i>=0;i--)
cin>>a[i];
while(r-l>1e-7)
{
double mid=(l+r)/2;
if(f(mid+1e-7)>f(mid-1e-7)) l=mid;
else r=mid;
}
printf("%.7lf",l);
}