hdu2199_Can you solve this equation?
来源:互联网 发布:wifi共享大师for mac 编辑:程序博客网 时间:2024/06/07 00:30
这个题二分比较明显,但是二分法要注意返回的值,返回不同的值有精度问题。
#include <stdio.h>
#include <math.h>double an(double x)
{
return 8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*x+6;
}
double bs(double low,double high,double y)
{
double mid;
while(high-low>1e-7)
{
mid=(high+low)/2;
if(an(mid) > y) high=mid;
else low=mid;
}
return high;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
double y;
scanf("%lf",&y);
if(y<an(0)||y>an(100.0))
printf("No solution!\n");
else
printf("%.4lf\n",bs(0,100,y));
}
return 0;
}
0 0
- hdu2199_Can you solve this equation?
- Can you solve this equation?
- Can you solve this equation?
- Can you solve this equation?
- Can you solve this equation?
- Can you solve this equation?
- hdu2199Can you solve this equation?
- Can you solve this equation?
- Can you solve this equation?
- Can you solve this equation?
- Can you solve this equation?
- hdoj2199Can you solve this equation?
- Can you solve this equation?
- Can you solve this equation?
- Can you solve this equation?
- Can you solve this equation
- Can you solve this equation?
- Can you solve this equation?
- Linearization of the kernel functions in SVM
- Map性能测试-用16G内存在Java Map中处理30亿对象
- DataGridView增加新行(合计行)
- C++ 模版类的单向循环链式线性表
- 在Xcode4.5中禁用ARC(Automatic Referencing Counting)
- hdu2199_Can you solve this equation?
- ajax不执行success回调而是执行error回调
- N叉树商业模式都不具有可持续性
- SQL 锁
- 数据结构与算法汇总
- Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds
- tyvj-2049 魔法珠
- hdu2899_Strange fuction
- 异常java.util.concurrent.ConcurrentHashMap.keySet()Ljava/util/concurrent/ConcurrentHashMap$KeySetView;