Can you solve this equation?

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7493    Accepted Submission(s): 3484

Problem Description
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.
 
Input
The 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);
 
Output
For 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!
 
Author
Redow
 
Recommend
lcy   |   We have carefully selected several similar problems for you:  2899 2289 2298 3400 1969 

 
  二分搜索
  先要判断方程的单调性。可用 cal()<=y && y<=cal() 判断。
  二分法不断提高精度,最后到某个精度位置输出就是正确答案。
  注意题目给出的第一组测试数据是错的,AC代码出来的结果是1.6151,而不是1.6152。
  代码:
 #include <iostream>
#include <cmath>
#include <iomanip>
using namespace std; double cal(double x)
{
return *pow(x,) + *pow(x,) + *pow(x,) + *x + ;
}
double GetAns(double y)
{
double a=,b=;
while(b-a>1e-){
double mid=(a+b)/;
cal(mid)<y?a=mid:b=mid;
}
return (a+b)/;
}
int main()
{
int T;
cin>>T;
while(T--){
double y;
cin>>y;
if(cal()<=y && y<=cal()){
cout<<setiosflags(ios::fixed)<<setprecision();
cout<<GetAns(y)<<endl;
}
else
cout<<"No solution!"<<endl;
}
return ;
}

Freecode : www.cnblogs.com/yym2013

hdu 2199:Can you solve this equation?(二分搜索)的更多相关文章

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

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

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

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

  4. HDU 2199 Can you solve this equation?(二分解方程)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/10 ...

  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. UVa OJ 197 - Cube (立方体)

    Time limit: 30.000 seconds限时30.000秒 Problem问题 There was once a 3 by 3 by 3 cube built of 27 smaller ...

  2. chrome 阻止跨域操作的解决方法 --disable-web-security

    做chrome插件时,遇到https页面上请求htttp页面资源时被blocked的问题,初苦寻解决方法未果,最后找到: 给chrome加上 --disable-web-security 参数

  3. How to Write and Publish a Scientific Paper: 7th Edition(科技论文写作与发表教程)(11.04更新)

    How to Write and Publish a Scientific Paper: 7th Edition(科技论文写作与发表教程)(11.04更新) 重要通知: 最近开题报告已差不多告一段落, ...

  4. 一步一步教你如何在linux下配置apache+tomcat(转)

    一步一步教你如何在linux下配置apache+tomcat   一.安装前准备. 1.   所有组件都安装到/usr/local/e789目录下 2.   解压缩命令:tar —vxzf 文件名(. ...

  5. C++构造函数详解及显式调用构造函数

    来源:http://www.cnblogs.com/xkfz007/archive/2012/05/11/2496447.html       c++类的构造函数详解                  ...

  6. Linux常用命令 查看进程信息时 copy的-----温故而知新

    1.查进程    ps命令查找与进程相关的PID号:    ps a 显示现行终端机下的所有程序,包括其他用户的程序.    ps -A 显示所有程序.    ps c 列出程序时,显示每个程序真正的 ...

  7. Java主流日志工具库

    在项目开发中,为了跟踪代码的运行情况,常常要使用日志来记录信息.在Java世界,有很多的日志工具库来实现日志功能,避免了我们重复造轮子.我们先来逐一了解一下主流日志工具. 1.java.util.lo ...

  8. Run UliPad 4.1 Under Windows 7 64bit and wxPython 3.0.2

    Abstract: UliPad that is developed by limodou is an excellent code editor. It works well with wxPyth ...

  9. Linux下的网络管理工具—OpenNMS

    导读 OpenNMS的是一个运营商级别的,高度集成的,开放源码的平台,用于构建网络监控解决方案.OpenNMS有两个发行版:Meridian and Horizon.使用Meridian是可取的,对企 ...

  10. [BZOJ2303][Apio2011]方格染色

    [BZOJ2303][Apio2011]方格染色 试题描述 Sam和他的妹妹Sara有一个包含n × m个方格的 表格.她们想要将其的每个方格都染成红色或蓝色. 出于个人喜好,他们想要表格中每个2 × ...