这题我用三分来做。
#include<iostream>
#include<string.h>
#include<string>
#include<stack>
#include<queue>
#include<functional>
#include<set>
#include<map>
#include<stdlib.h>
#include<vector>
#include<math.h>
#include <algorithm>
#pragma warning(disable:4996)
using namespace std;
double EPS = 1e-6;
double find(double x,double y)
{
return 6 * pow(x, 7) + 8 * pow(x, 6) + 7 * pow(x, 3) + 5 * pow(x, 2) - y*x;
}
double sf(double y)
{
double lo=0, r=100,mid,mmid;
while(r-lo>EPS)
{
mid = (r + lo)/2;
mmid = (mid + r)/2;
if (find(mid,y) < find(mmid,y))
r = mmid;
else
lo = mid;
}
return lo;
}
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
double y;
scanf("%lf", &y);
double d = sf(y);
printf("%.4lf\n", find(d,y));
}
return 0;
}