我们可以发现这个函数是单增的,那么这样二分就好了。

  反思:刚转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 二分的更多相关文章

  1. 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 == ...

  2. hdu 4024 二分

    转自:http://www.cnblogs.com/kuangbin/archive/2012/08/23/2653003.html   一种是直接根据公式计算的,另外一种是二分算出来的.两种方法速度 ...

  3. hdu 2199 (二分)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 ...

  4. 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 ...

  5. 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 ...

  6. HDU 2199 Can you solve this equation? (二分 水题)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  7. HDU 2199 Can you solve this equation(二分答案)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  8. HDU - 2199 Can you solve this equation? 二分 简单题

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  9. hdu 2199 Can you solve this equation? 二分

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

随机推荐

  1. javaweb引用jar类库的问题

    JAVAWEB中,需要引用的jar类库必须放在/WebContent/WEB-INF/lib文件夹中.不然就会各种报错.

  2. C# Excel2007 导出生成 2003兼容格式

    //导出2007格式 AppWb.Saved = true; //保存工作薄 AppExcel.ActiveWorkbook.SaveCopyAs(FilePath); //导出2003格式 AppW ...

  3. 【Docker 命令】- push 命令

    docker push : 将本地的镜像上传到镜像仓库,要先登陆到镜像仓库 语法 docker push [OPTIONS] NAME[:TAG] OPTIONS说明: --disable-conte ...

  4. iis7 appcmd命令

    iis中提供了appcmd命令 可以通过命令行来配置iis appcmd.exe 默认路径在 c:\windows\system32\inetsrv\下 若要回收应用程序池,请使用以下语法: appc ...

  5. navicat for mysql 10.1.7 注册码

    NAVN-LNXG-XHHX-5NOO名:组织:注册码:均为NAVN-LNXG-XHHX-5NOO 下载地址:http://www.cr173.com/soft/38153.html

  6. Matlab画平滑曲线的两种方法

    自然状态下,用plot画的是折线,而不是平滑曲线. 有两种方法可以画平滑曲线,第一种是拟合的方法,第二种是用spcrv,其实原理应该都一样就是插值.下面是源程序,大家可以根据需要自行选择,更改拟合的参 ...

  7. 从Mysql某一表中随机读取n条数据的SQL查询语句

    若要在i ≤ R ≤ j 这个范围得到一个随机整数R ,需要用到表达式 FLOOR(i + RAND() * (j – i + 1)).例如, 若要在7 到 12 的范围(包括7和12)内得到一个随机 ...

  8. 【Python】Python中的下划线

    单下划线(如: _var): 使用单下划线,用于指定该名变量或函数属性为“私有”.这仅仅是一个惯例,不是强制规定.用于向其他程序员表明这个变量或函数仅仅供内部使用,外部不要访问它.但实际上外部还是可以 ...

  9. 使用dom4j修改XML格式的字符串

    XML格式 <data> <ryzd> <record> <western> <record> <diagnoses> < ...

  10. 【bzoj5064】B-number 数位dp

    题目描述 B数的定义:能被13整除且本身包含字符串"13"的数. 例如:130和2613是B数,但是143和2639不是B数. 你的任务是计算1到n之间有多少个数是B数. 输入 输 ...