先求导,在二分……
#include "stdio.h"
#include "math.h"
#define er 1e-4
double get_equ(double x)
{
return 42*pow(x,6)+48*pow(x,5)+21*x*x+10*x;
}
int main()
{
int T;
double y;
double mid,left,right;
scanf("%d",&T);
while(T--)
{
scanf("%lf",&y);
left=0;
right=100;
mid=50;
while(fabs(get_equ(mid)-y)>er)
{
if(get_equ(mid)-y<0)
{
left=mid;
mid=(left+right)/2;
}
else
{
right=mid;
mid=(left+right)/2;
}
}
printf("%.4lf\n",6*pow(mid,7)+8*pow(mid,6)+7*pow(mid,3)+5*mid*mid-y*mid);
}
return 0;
}