2001
来源:互联网 发布:wer机器人编程 编辑:程序博客网 时间:2024/05/16 19:21
2001
Problem DescriptionNow,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100;<br>Now please try your lucky.InputThe first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines follow, each line has a real number Y (fabs(Y) <= 1e10);OutputFor each test case, you should just output one real number(accurate up to 4 decimal places),which is the solution of the equation,or “No solution!”,if there is no solution for the equation between 0 and 100.Sample Input2<br>100<br>-4<br>Sample Output1.6152<br>No solution!<br>AC代码:#include<cmath>简单题意:给定一个方程,在0—100之间寻找解思路:直接使用二分法即可;
#include<cstdio>
#define eps 1e-8
double fun(double x)
{
return 8*x*x*x*x + 7*x*x*x + 2*x*x + 3*x + 6;
}
int main()
{
double y,a,b,m,d;
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lf",&y);
if(y<6 || y>807020306)
{
printf("No solution!\n");
continue;
}
a=0.0;
b=100.0;
while(b-a>eps)
{
m=(a+b)/2;
if(fun(m)<y)
a=m;
else
b=m;
}
printf("%.4f\n",a);
}
return 0;
}
0 0
- 2001
- 2001
- 2001
- 2001
- 2001
- 2001年题
- poj 2001
- 2001年
- zoj 2001
- Verilog-2001
- HDU 2001
- poj 2001
- poj 2001
- poj 2001
- poj 2001
- poj 2001
- hdu 2001
- HDU 2001
- C++源码网站
- org.apache.commons.collections.CollectionUtils
- 项目一(3)三角形雏形
- 利用canvas实现田字格里写字,并适配移动端
- 链表类的设计与实现(智能指针)
- 2001
- 7.【项目 1-成员函数、友元函数和一般函数有区别】
- springmvc 采用MultipartResolver进行文件上传
- 第三周项目:年龄几何
- 简单实现三级缓存加载图片机制
- 第七周项目训练2 友员类
- MySQL基础九:MySQL存储引擎
- algrothm_bata structure_base3
- 数据库中的命名规则