hdu 2675 二分 解方程

来源:互联网 发布:软件开发创业前景 编辑:程序博客网 时间:2024/05/22 06:04
</pre><pre name="code" class="cpp">#include<iostream>#include<cmath>#include<cstdio>using namespace std;const double e=2.718281828459;int main(){double  c,b,y,left,right,mid;while(scanf("%lf",&y)!=EOF){b=e*y/log(e*y);if(fabs(y-1)<0.00000001)printf("%.5lf\n",e);else{left=1,right=e;while(right-left>0.000000001){mid=(left+right)/2;c=mid/log(mid);if(c<b)right=mid;elseleft=mid;}printf("%.5lf ",mid);left=e;right=1000000000;while(right-left>0.000000001){mid=(left+right)/2;if((mid/log(mid))>b)right=mid;elseleft=mid;}printf("%.5lf\n",mid);}}return 0;}


0 0
原创粉丝点击