HDU 2199 (13.08.07)
来源:互联网 发布:wings重组知乎 编辑:程序博客网 时间:2024/04/24 20:09
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.
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
2100-4
Sample Output
1.6152No solution!此题用二分法求解~
AC代码:
#include<stdio.h>double f(double x) { return (8*x*x*x*x + 7*x*x*x + 2*x*x + 3*x + 6);}double myabs(double x) { if(x < 0) return x * (-1); else return x;}int main() { int T; scanf("%d", &T); while(T--) { double begin = 0.0; double end = 100.0; double mid; double Y; scanf("%lf", &Y); if(f(0.0) > Y || f(100.0) < Y) { printf("No solution!\n"); continue; } mid = (begin + end) / 2; while(myabs(f(mid) - Y) > 1e-5) { if(f(mid) > Y) { end = mid; mid = (begin + end) / 2; } else if(f(mid) < Y){ begin = mid; mid = (begin + end) / 2; } } printf("%.4lf\n", mid); } return 0;}
- HDU 2199 (13.08.07)
- HDU 2199
- HDU 2199
- hdu 2199
- HDU 2199
- HDU 2199
- hdu 2199
- HDU-2199
- HDU-2199
- HDU 2199
- HDU 4287 (13.08.17)
- HDU 4642 (13.08.25)
- HDU-2199 二分法
- HDU-2199(search_bin-精度)
- HDU-2199 二分查找
- hdu 2199 二分法!!!
- hdu 2199 二分
- hdu 2199 二分
- MFC实现透明画刷
- hdu 题目1445 Stick(DFS+剪枝)
- 彻底征服Windows上OpenVPN客户端的源地址选择问题
- Graeffe法求解多项式方程单实根
- 动态代理设计模式
- HDU 2199 (13.08.07)
- Lin法求解多方式方程共轭复根
- android中各种颜色值
- 712 - S-Trees
- 网络及网络协议
- Newton_Raphson法求解非线性方程
- APK反编译后代码分析(二)
- html中的颜色代码详解及图示
- hdu3496 Watch The Movie (二维背包)