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

  反思:刚转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. TCP系列07—连接管理—6、TCP连接管理的状态机

            经过前面对TCP连接管理的介绍,我们本小节通过TCP连接管理的状态机来总结一下看看TCP连接的状态变化 一.TCP状态机整体状态转换图(截取自第二版TCPIP详解) 二.TCP连接建立 ...

  2. .net 内置对象之Session对象和Session的过期时间

    QQ:827969653 有需要的朋友可以下载Session类:SessionHelper类 http://technet.microsoft.com/zh-cn/library/system.web ...

  3. phpcms黄页,不能选择行业。解决办法

    用phpcms黄页模块,发布产品的时候.不能选择 产品分类,点开之后,啥都没有,是空的. 这个是因为:js的问题. 解决办法:将 网站根目录的 js 文件中的两个文件,更换为 官方的两个js文件.即可 ...

  4. 调度的log 1.5ms 12ms 4ms

    36   37   38            loopM 24369 [001] 60789.192708: sched:sched_switch: prev_comm=loopM prev_pid ...

  5. hdu 3030 Increasing Speed Limits (离散化+树状数组+DP思想)

    Increasing Speed Limits Time Limit: 2000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java ...

  6. BZOJ1012:[JSOI2008]最大数——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=1012 https://www.luogu.org/problemnew/show/P1198 现在 ...

  7. BZOJ4571:[SCOI2016]美味——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=4571 https://www.luogu.org/problemnew/show/P3293 一家 ...

  8. C/C++中字符串与数字相互转换

    数字转字符串: 用C++的streanstream: #include <sstream> #Include <string> string num2str(double i) ...

  9. crontab使用进程锁解决冲突

    想到一个问题,如果在crontab里有个定时任务设置为一分钟执行一次,但是它执行的时间可能会超过一分钟,此时crontab一分钟后会再次运行该脚本吗?这样会不会出现冲突呢?网上找了下,说可以用Linu ...

  10. HDU 1045 dfs

    Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...