hdu 2199

 1 //二分查找
 2 #include<stdio.h>
 3 #include<math.h>
 4 #define eps 1e-7
 5 double fun(double x)
 6 {
 7     return 8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*x+6;
 8 }
 9 double bin_search(double Y)
10 {
11     double low=0.0,high=100.0,mid;
12     while(high-low>eps)
13     {
14         mid=(low+high)/2.0;
15         if(fun(mid)<Y)
16             low=mid+eps;
17         else
18             high=mid-eps;
19     }
20     return (low+high)/2;
21 }
22 int main()
23 {
24     int t;
25     double Y,ans;
26     scanf("%d",&t);
27     while(t--)
28     {
29         scanf("%lf",&Y);
30         if(fun(0)<=Y&&Y<=fun(100))
31         {    
32             ans=bin_search(Y);
33             printf("%.4lf\n",ans);
34         }
35         else
36             printf("No solution!\n");
37     }
38     return 0;
39 }

 

转载于:https://www.cnblogs.com/M-cag/archive/2012/08/09/2630567.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值