hdoj 2199
作者:互联网
#include<bits/stdc++.h>
using namespace std;
#define f(x) (x*(x*(x*(x*8+7)+2)+3)+6)
double bsearch(double l,double r,double x)
{
double mid;
while(r-l>1e-7)
{
mid=(l+r)/2;
if(f(mid)<x)
{
l=mid;
}
else
{
r=mid;
}
}
return (l+r)/2;
}
int main(void)
{
int n;
double m;
scanf("%d",&n);
double f0,f100;
f0=f(0.0);
f100=f(100.0);
while(n--)
{
scanf("%lf",&m);
if(m<f0||m>f100)
{
printf("No solution!\n");
}
else
{
printf("%.4f\n",bsearch(0,100,m));
}
}
return 0;
}
标签:f0,int,double,mid,printf,2199,f100,hdoj 来源: https://blog.csdn.net/rch2020082203/article/details/115589016