Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7493 Accepted Submission(s): 3484
1 #include <iostream>
2 #include <cmath>
3 #include <iomanip>
4 using namespace std; 5
6 double cal(double x) 7 { 8 return 8*pow(x,4) + 7*pow(x,3) + 2*pow(x,2) + 3*x + 6; 9 } 10 double GetAns(double y) 11 { 12 double a=0,b=100; 13 while(b-a>1e-6){ 14 double mid=(a+b)/2; 15 cal(mid)<y?a=mid:b=mid; 16 } 17 return (a+b)/2; 18 } 19 int main() 20 { 21 int T; 22 cin>>T; 23 while(T--){ 24 double y; 25 cin>>y; 26 if(cal(0)<=y && y<=cal(100)){ 27 cout<<setiosflags(ios::fixed)<<setprecision(4); 28 cout<<GetAns(y)<<endl; 29 } 30 else
31 cout<<"No solution!"<<endl; 32 } 33 return 0; 34 }
Freecode : www.cnblogs.com/yym2013