hdu - 2199
谜一样的精度控制
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long int lld;
double y;
double f(double x)
{
return 8*x*x*x*x+7*x*x*x+2*x*x+3*x+6;
}
double fin(double a,double b)
{
double x=(a+b)/2.0;
if(b-a<1e-6)return x;
if(f(x)>y) return fin(a,x);
if(f(x)<y) return fin(x,b);
}
int main()
{
int n;
cin>>n;
while(n--){
cin>>y;
if(y<f(0)||y>f(100)){
printf("No solution!\n");
}else{
// cout<<fin(0,100)<<endl;
printf("%.4f\n",fin(0,100));
}
}
}