Problem Description

Now, here is afuction:<br>&nbsp;&nbsp;F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0&lt;= x &lt;=100)<br>Can you find the minimum value when x isbetween 0 and 100.

Input

The first line of the inputcontains an integer T(1<=T<=100) which means the number of test cases.Then T lines follow, each line has only one real numbers Y.(0 < Y <1e10)

Output

Just the minimum value(accurate up to 4 decimal places),when x is between 0 and 100.

Sample Input

2

100

200

Sample Output

-74.4291

-178.8534

简单三分或二分求导实现

`#include <iostream>#include <stdio.h>#include <string.h>#include <stack>#include <queue>#include <map>#include <set>#include <vector>#include <math.h>#include <bitset>#include <algorithm>#include <climits>#define maxn 50005using namespace std;typedef long long ll;double f(double x){  return 42*pow(x,6)+48*pow(x,5)+21*x*x+10*x;}double f1(double x,double y){  return 6*pow(x,7)+8*pow(x,6)+7*pow(x,3)+5*x*x-y*x;}int main(){  int T;  scanf("%d",&T);  double n;  while(T--)  {    scanf("%lf",&n);    double l=0,r=100;    while(l+1e-8<r)    {      double mid=(l+r)/2;            //cout<<mid<<endl;      if(f(mid)>=n)        r=mid;      else        l=mid;    }    //cout<<l<<endl;    printf("%.4lf\n",f1(l,n));  }  return 0;}`
`#include<bits/stdc++.h>using namespace std; double y;double cal(double mid){    return 6*pow(mid,7)+8*pow(mid,6)+7*pow(mid,3)+5*pow(mid,2)-y*mid;}int main(){   int T;   cin>>T;   int i;   for(i=1;i<=T;i++)   {       cin>>y;        double low=0,high=100,mid,midmid;        while(high-low>1e-9)//开始连续查找函数       {           mid=(low+high)/2;           midmid=(mid+high)/2;           double cmid=cal(mid);           double cmidmid=cal(midmid);           if(cmid<cmidmid)            high=midmid;           else            low=mid;       }             printf("%.4lf\n",cal(mid));   }    return 0;}`