杭电 HDU 2199
来源:互联网 发布:ultraiso软件有多大 编辑:程序博客网 时间:2024/05/22 22:13
Can you solve this equation?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 19266 Accepted Submission(s): 8484
Problem Description
Now,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;
Now please try your lucky.
Input
The 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);
Output
For 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 Input
2
100
-4
Sample Output
1.6152
No solution!
#include<cstdio>#include<math.h>double h(double x){ return 8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*x+6;}int main(){ int t; scanf("%d",&t); while(t--) { double y; scanf("%lf",&y); if(y>=h(0)&&y<=h(100)) /// 保证y值的范围 { double l=0; ///二分思想 double r=100; while(r-l>1e-7) ///注意精度 { double m=(l+r)/2.0; if(h(m)<y) { l=m+1e-8; } else { r=m-1e-8; } }printf("%.4lf\n",(l+r)/2.0); } else printf("No solution!\n"); }}
- 杭电 HDU 2199
- 杭电 hdu 3415
- 杭电 hdu 1009
- 【HDU 杭电 1155】
- 杭电 hdu 2614 Beat
- hdu 杭电acm 1002
- 杭电ACM HDU 1004
- 杭电ACM HDU 1002
- 杭电ACM HDU 1008
- 杭电ACM HDU 1013
- 杭电ACM HDU 1014
- 杭电hdu 逃离迷宫
- 杭电 HDU 1072 Nightmare
- 杭电 HDU 1242 Rescue
- 杭电2111-Saving HDU
- 杭电HDU-1106排序
- 杭电hdu题目分类
- 杭电 HDU 1020 Encoding
- 线程安全
- 6.Java常用API 2
- 深入理解MySQL的四种隔离级别
- 大数据分析的技术栈(一)-HBase, Parquet
- 470_自己onDraw的点击
- 杭电 HDU 2199
- 471_圆形ImageView
- PowerShell/PowerShellでメールを送信するサンプルコード
- 论文Deep Learning for Identifying Metastatic Breast Cancer论文心得
- 472_无法滚动的ViewPager
- 7.集合1
- 二叉搜索树
- @RequestMapping注解的用法
- Number对象,Math对象,Array对象