hdu 2199 Can you solve this equation

心情不好,简单的二分

#include<iostream>#include<cstdio>#include<cmath> using namespace std;double y;int cal(double x){return 8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*x+6;}double find(){double mid;double a,b;a=0;b=100;while(b-a>1e-8){mid=(a+b)/2;if(cal(mid)<y) a=mid;elseb=mid;}return (a+b)/2.0;}int main(){int t;cin>>t;while(t–){cin>>y;if(cal(0)<=y&&y<=cal(100)) printf("%.4f\n",find());else cout<<"No solution!"<<endl;}return 0;}

,每一发奋努力的背后,必有加倍的赏赐。

hdu 2199 Can you solve this equation

相关文章:

你感兴趣的文章:

标签云: