Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6763 Accepted Submission(s): 3154
1 /* 2 对于精度,我表示囧。 3 我以为,保留4位小数,就到1e-5就可以了。 4 5 */ 6 7 #include<iostream> 8 #include<stdio.h> 9 #include<cstring> 10 #include<cstdlib> 11 #include<math.h> 12 using namespace std; 13 14 double fun(double x) 15 { 16 return 8*x*x*x*x+7*x*x*x+2*x*x+3*x+6; 17 } 18 void EF(double l,double r,double Y) 19 { 20 double mid; 21 while(r-l>1e-7) 22 { 23 mid=(l+r)/2; 24 double ans=fun(mid); 25 if( ans >Y ) 26 r=mid-1e-8; 27 else l=mid+1e-8; 28 } 29 printf("%.4lf\n",(l+r)/2); 30 } 31 int main() 32 { 33 int T; 34 double Y; 35 scanf("%d",&T); 36 { 37 while(T--) 38 { 39 scanf("%lf",&Y); 40 if( fun(0.0)>Y || fun(100.0)<Y) 41 printf("No solution!\n"); 42 else 43 EF(0.0,100.0,Y); 44 } 45 } 46 return 0; 47 }