hdu 2199

单调递增,二分搜索。。。

 1 #include<stdio.h>
 2 #define p2(x) ((x)*(x))
 3 #define p3(x) (p2(x)*(x))
 4 #define p4(x) (p2(x)*p2(x))
 5 
 6 double cal(double x)
 7 {return 8*p4(x)+7*p3(x)+2*p2(x)+3*x+6;}
 8 
 9 int main()
10 {
11     int t;
12     scanf("%d",&t);
13     while(t--)
14     {
15         double y;
16         scanf("%lf",&y);
17         if(cal(0)>y||cal(100)<y)
18         {
19             printf("No solution!\n");
20             continue;
21         }
22         double l=0,r=100,tmp;
23         while(r-l>1e-6)
24         {
25             double mid=l/2+r/2;
26             if(cal(mid)>y)
27                 r=mid;
28             else
29                 l=mid;
30         }
31         printf("%.4lf\n",r/2+l/2);
32     }
33 }

 

转载于:https://www.cnblogs.com/zerojetlag/archive/2013/04/03/2997628.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值