这道题只要求出导数为零的点再带入原方程即可
#include <stdio.h>
#include <math.h>
double daoshu(double x)
{
return 42*pow(x,6)+48*pow(x,5)+21*pow(x,2)+10*x;
}
double bs(double low,double high,double y)
{
double mid;
while(high-low>1e-7)
{
mid=(high+low)/2;
if(daoshu(mid) > y) high=mid;
else low=mid;
}
return high;
}
double ans(double x,double y)
{
return 6*pow(x,7)+8*pow(x,6)+7*pow(x,3)+5*pow(x,2)-y*x;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
double y;
scanf("%lf",&y);
printf("%.4lf\n",ans(bs(0,100,y),y));
}
return 0;
}