题意简单,题目也没什么难度,注意下精度就好了
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <ctime>
using namespace std;
double dis(double x)
{
return (8*x*x*x*x +7*x*x*x+2*x*x+3*x+6);
}
int main()
{
int t;
double y;
int flag;
scanf("%d",&t);
while(t--)
{
flag=1;
scanf("%lf",&y);
if((dis(0)>y)||(dis(100)<y))
{
flag=0;
}
double low=0.0;
double high=100.0;
double mid;
while((fabs(high-low)>1e-8)&&flag==1)//注意精度判断
{
mid=(low+high)/2;
if(dis(mid)<y)
{
low=mid;
}
else
{
high=mid;
}
}
if(flag==0)
{
cout<<"No solution!"<<endl;
}
else
{
printf("%.4f\n",mid);
}
}
return 0;
}