Can you solve this equation? -----HDU 2199
来源:互联网 发布:linux voip服务器 编辑:程序博客网 时间:2024/05/22 16:59
这道题就是入门的一道二分法水题,思路很简单每次找他的一半,当头和尾逼近所设的精度时,答案就出来了
#include <cstdio>#include <cmath>double y;const double eps=1e-10;double zhi(double x){ return 8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*x+6-y;}main (){ int t; scanf("%d",&t); while (t--) { double ans; scanf("%lf",&y); double l=0,r=100,mid; if(zhi(l)>eps||zhi(r)<eps) { printf("No solution!\n"); continue; } while (l+eps<=r) { mid=(l+r)/2; if(zhi(mid)<eps) l=mid+eps; else r=mid-eps; } printf("%.4lf\n",mid); }}
0 0
- hdu 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- HDU 2199-Can you solve this equation?
- hdu 2199 Can you solve this equation?
- hdu 2199 can you solve this equation
- HDU 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation?
- HDU 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation?
- hdu 2199 Can you solve this equation
- hdu-2199 Can you solve this equation?
- 使用 C++ Builder 创建应用程序
- 快速理解Docker - 容器级虚拟化解决方案
- leetcode 141. Linked List Cycle
- SQL 存储过程里调用另一个存储过程
- Java异常处理和设计
- Can you solve this equation? -----HDU 2199
- codefroces14B
- RasCustomDeleteEntryNotify
- ACdream 1773 最长非回文串
- leetcode 345. Reverse Vowels of a String
- Catch That Cow
- leetcode 24. Swap Nodes in Pairs
- Linux 命令行历史及其history
- [POJ3189][cqbzoj1640]稳定的奶牛分配 解题报告