HDU 2199 二分
我们可以发现这个函数是单增的,那么这样二分就好了。
反思:刚转C++,不会用scanf读入实数。(scanf("%lf",&y))
//By BLADEVIL
#include <cstdio>
#include <iostream> using namespace std; double f(double x) {
return (*x*x*x*x+*x*x*x+*x*x+*x+);
} int task,y; int main() {
scanf("%d",&task);
double left=f(),right=f();
while (task--) {
cin>>y;
//printf("%.4f ",y);
if ((y<left)||(y>right)) {
printf("No solution!\n");
continue;
}
double l=,r=,ans;
for (int i=;i<=;i++) {
double mid=(l+r)/;
if (f(mid)>y) {
ans=mid;
r=mid-;
} else l=mid+;
}
printf("%.4f\n",ans);
}
return ;
}
HDU 2199 二分的更多相关文章
- HDU 2199 Can you solve this equation?(二分精度)
HDU 2199 Can you solve this equation? Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == ...
- hdu 4024 二分
转自:http://www.cnblogs.com/kuangbin/archive/2012/08/23/2653003.html 一种是直接根据公式计算的,另外一种是二分算出来的.两种方法速度 ...
- hdu 2199 (二分)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 ...
- hdu 2199 Can you solve this equation?(高精度二分)
http://acm.hdu.edu.cn/howproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS ...
- ACM:HDU 2199 Can you solve this equation? 解题报告 -二分、三分
Can you solve this equation? Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Su ...
- HDU 2199 Can you solve this equation? (二分 水题)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU 2199 Can you solve this equation(二分答案)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU - 2199 Can you solve this equation? 二分 简单题
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdu 2199 Can you solve this equation? 二分
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- C# 如何在winform中嵌入Excel,内嵌Excel,word
近使用.net做一个小软件遇到一个问题,就是想实现把excel表格在winform中打开,同时可以操作,不单单是打开.或者就提取数据.在网上找了好多资料,发现这方面的资料比较少,即使有,都是旧版本的使 ...
- 访问需要HTTP Basic Authentication认证的资源的各种开发语言的实现
什么是HTTP Basic Authentication?直接看http://en.wikipedia.org/wiki/Basic_authentication_scheme吧. 在你访问一个需要H ...
- 图像检测算法Halcon 10的使用
安装完成HALCON之后,在VS项目中添加动态链接库配置项目,并修改此项目属性的包含目录.库目录和链接器.
- Java 多线程 三种实现方式
Java多线程实现方式主要有三种:继承Thread类.实现Runnable接口.使用ExecutorService.Callable.Future实现有返回结果的多线程.其中前两种方式线程执行完后都没 ...
- Delphi处理事件函数中的Sender: TObject代表什么?
下面这个按钮点击事件中,Sender代表谁? procedure Tsomain.ToolButton1Click(Sender: TObject); 是代表事件的拥有者吗? procedure TF ...
- 【bzoj4832】[Lydsy2017年4月月赛]抵制克苏恩 概率期望dp
题目描述 你分别有a.b.c个血量为1.2.3的奴隶主,假设英雄血量无限,问:如果对面下出一个K点攻击力的克苏恩,你的英雄期望会受到到多少伤害. 输入 输入包含多局游戏. 第一行包含一个整数 T (T ...
- CMD命令提示符
mspaint 画图板 notepad 打开记事本 write 写字板 calc.exe 计算器 control.exe 控制面板 osk 打开屏幕键盘 rononce -p ----15 ...
- 源码安装和yum安装的区别。
yum是将yum源中别人已经编译好的rpm包下载到本地,然后安装,不需要考虑依赖,主要是方便.源码安装没法人为的控制,安装的版本也很低. 源码安装需要自己编译,安装,编译过程中可以设置参数.可安装的版 ...
- BZOJ1070:[SCOI2007]修车——题解
http://www.lydsy.com/JudgeOnline/problem.php?id=1070 https://www.luogu.org/problemnew/show/P2053#sub ...
- vue-router的钩子
vue-router的钩子分为三类: 1. 全局钩子2. 路由独享钩子3. 组件内钩子 1. 全局钩子 beforeEach(to,from,next) afterEach(route) 2. 路由独 ...