hdoj 2199二分查找
来源:互联网 发布:北京网络策划公司 编辑:程序博客网 时间:2024/06/11 11:09
给出方程:
8*x4 + 7*x3 + 2*x2 + 3*x + 6 = Y
其中,实数Y满足 (fabs(Y) <= 1e10)
请输出x在区间[0,100]的解,结果精确到小数点后4位。
看着 课件写的 ,慢慢理解 中
#include <iostream>#include <cstdio>#include <cmath>using namespace std;double y;double l,r,m;double f(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--) { scanf("%lf",&y); if(y>=f(0)&&y<=f(100)) { l=0; r=100; while(r-l>1e-6) { m=(l+r)/2; double ans=f(m); if(ans>y) r=m-1e-7; else l=m+1e-7; } printf("%.4lf\n",(l+r)/2); } else printf("No solution\n"); } return 0;}
1 0
- hdoj 2199二分查找
- HDOJ 1969 Pie(二分查找)
- hdoj 2199 Can you solve this equation?【二分查找】【水】
- HDOJ 2199 Can you solve this equation?(二分查找法)
- HDOJ-2199-Can you solve this equation?(二分查找)
- HDOJ Can you solve this equation? 2199【二分查找】
- HDOJ 2199 Can you solve this equation?(二分查找)
- hdoj 2199 Can you solve this equation? 【二分查找】
- [HDOJ 4938] Seeing People [排序+二分查找]
- HDOJ 1551 Cable master(二分查找)
- hdoj--1950--Bridging signals(二分查找+LIS)
- hdoj 5048 序列变换 (二分查找)
- hdoj 3763 CD(二分查找)
- hdoj 2199二分搜索
- HDOJ-----2199二分
- HDU-2199 二分查找
- HDU 2199 二分查找
- HDOJ 1394 - Minimum Inversion Number 求逆序对+二分查找
- Hadoop YARN常见问题以及解决方案
- oracle 中使用 rownum 的一个误区
- 【00】【小菜鸟学习虚拟化】之前言篇
- 字符流_FileReader类
- 京东2016实习生招聘笔试真题-技术岗位选择题A
- hdoj 2199二分查找
- 如何在zigbee的应用层修改PANID?
- caffe loss一直nan什么情况
- Climbing Worm
- android 本地存储的几种方式
- 音频 图像 视频等数据的压缩与存储格式
- 字符流_FileWriter类
- 操作系统:进程的状态
- IDEA搭建Web项目