主要思想就是两端逼近,最后得到结果,0MS
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm> using namespace std; const double ep = 1e-; double deal(double n)
{
return *pow(n,) + *pow(n,) + *pow(n,) + *n + ; } int main()
{
int t,i;
double y;
scanf("%d",&t);
while (t--)
{
scanf("%lf",&y);
double lo = ,hi = ;
if(y<deal() || y>deal())
{
printf("No solution!\n");
continue;
}
else
{
double mid;
while(hi-lo>ep)
{
mid = (lo+hi)/;
if(deal(mid)>y)
{
hi = mid;
}
else
{
lo = mid;
}
}
printf("%.4lf\n",hi);
} }
return ;
}