2 100 200
-74.4291 -178.8534
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
double y;
double A(double x)
{
return 42*pow(x,6)+48*pow(x,5)+21*pow(x,2)+10*x;
}
int main()
{
int T;
cin>>T;
while(T--)
{
double low=0.0;
double high=100.0;
double mid;
cin>>y;
if(A(100)<y)
{
printf("%.4lf",6*pow(100,7)+8*pow(100,6)+7*pow(100,3)+5*pow(100,2)-y*100);
continue;
}
while(low+1e-8<high)
{
mid=(low+high)/2.0;
if(A(mid)>y)
high=mid;
else
low=mid;
}
printf("%.4lf\n",6*pow(low,7)+8*pow(low,6)+7*pow(low,3)+5*pow(low,2)-y*low);
}
return 0;
}
原文地址:http://blog.csdn.net/lsgqjh/article/details/45418375