View Code
1 #include<stdio.h> 2 #include<math.h> 3 4 double func( double x,double y ){ 5 double ans; 6 ans=6*pow( x,7.0 )+8*pow( x,6.0 )+7*pow( x,3.0 )+5*pow( x,2.0 )-y*x; 7 return ans; 8 } 9 10 int main(){ 11 int T; 12 scanf("%d",&T); 13 while( T-- ){ 14 double y; 15 scanf("%lf",&y); 16 double left,right,mid,mmid; 17 left=0,right=100; 18 double delta=1e-8; 19 while( left<right-delta ){ 20 mid=(left+right)/2.0; 21 mmid=( mid+right )/2.0; 22 if( func( mid,y )<func( mmid,y ) ) right=mmid; 23 else left=mid; 24 } 25 printf("%.4lf\n",func( mid,y )); 26 } 27 return 0; 28 }
满足函数的凹凸性即可用三分。