Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100; 
Now please try your lucky.

InputThe first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines follow, each line has a real number Y (fabs(Y) <= 1e10);OutputFor each test case, you should just output one real number(accurate up to 4 decimal places),which is the solution of the equation,or “No solution!”,if there is no solution for the equation between 0 and 100.Sample Input

2
100
-4

Sample Output

1.6152
No solution! 思路:二分查找答案问题,设置精度后直接查找即可,代码如下:
double Y;

double check(double x) {
return * (x * x * x * x) + * (x * x * x) + * (x * x) + * x + ;
} int main() {
int T;
scanf("%d", &T);
while(T--) {
double l = 0.0, r = 100.0, mid;
scanf("%lf", &Y);
if(check(0.0) > Y || check(100.0) < Y) {
printf("No solution!\n");
continue;
}
while(r - l > 1e-) {
mid = (r + l) / 2.0;
if(check(mid) - Y > )
r = mid;
else
l = mid;
}
printf("%.4lf\n", mid);
}
return ;
}
												

Day3-K-Can you solve this equation? HDU2199的更多相关文章

  1. Can you solve this equation?---hdu2199(二分)

    http://acm.hdu.edu.cn/showproblem.php?pid=2199 给出y的值求x: 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 = Y x是0到100的 ...

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

  3. hdu 2199 Can you solve this equation?(二分搜索)

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

  4. hdu 2199:Can you solve this equation?(二分搜索)

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

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

  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. hdoj 2199 Can you solve this equation?【浮点型数据二分】

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

  8. Can you solve this equation?

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

  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. 给服务添加路由--ingress

    kind: NamespaceapiVersion: v1metadata:  name: demo-webshell  generateName: demo-webshell  labels:    ...

  2. Git 工作区、暂存区和版本库、操作流程

    Git 工作区.暂存区和版本库 基本概念 我们先来理解下Git 工作区.暂存区和版本库概念 工作区:就是你在电脑里能看到的目录. 暂存区:英文叫stage, 或index.一般存放在 ".g ...

  3. python中解方程

    from sympy import * import numpy as np from numpy import linalg # 方程中的符号 x = Symbol('x') # 计算 result ...

  4. PHP的自定义模板引擎

    前面的话 在大多数的项目组中,开发一个Web程序都会出现这样的流程:计划文档提交之后,前端工程师制作了网站的外观模型,然后把它交给后端工程师,它们使用后端代码实现程序逻辑,同时使用外观模型做成基本架构 ...

  5. Vagrant 安装使用

    先安装虚拟机 https://www.virtualbox.org/ 再安装 https://www.vagrantup.com/  1.nginxhttp://nginx.org/download/ ...

  6. JS获取CHECKBOX的值 AND 两个CHECKBOX 循环选中

    获取多选按钮的值 var chk_value = ''; $('input[data-action="checkRole"]:checked').each(function(){ ...

  7. 【转】bug management process

    What is Bug? A bug is the consequence/outcome of a coding fault What is Defect? A defect is a variat ...

  8. Windows 10 20H1版名称被定为Windows 10 Version 2004版以示区分

    导读 我们知道Windows 10 20H1 版目前的开发工作已经接近完成,当前微软主要通过新版本来修复部分已知的问题. 而名称上面按照以往规律推算应该是 Windows 10 Version 200 ...

  9. 关于Android file.createNewFile() 方法出现的问题总结(转)

    原文:http://blog.csdn.net/wjdarwin/article/details/7108606 今天在编写向SDcard中,创建文件夹并向其中保存文件的过程中出现个一系列的问题 在此 ...

  10. AngularJS四大特征

    AngularJS四大特征 1.MVC模式 Angular遵循软件工程的MVC模式,并鼓励展现,数据,和逻辑组件之间的松耦合.通过依赖注入(dependency injection),Angular为 ...