Day3-K-Can you solve this equation? HDU2199
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的更多相关文章
- 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的 ...
- 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?(高精度二分)
http://acm.hdu.edu.cn/howproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS ...
- HDU 2199 Can you solve this equation? (二分 水题)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdoj 2199 Can you solve this equation?【浮点型数据二分】
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- Can you solve this equation?
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- HDU 2199 Can you solve this equation(二分答案)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- 手把手教你使用Hexo+GitHub搭建自己的个人博客网站
安装nodejs环境 这个直接搜索安装即可,安装完成之后,通过如下命令检测环境变量是否安装成功: λ node -v # 输出版本号 v12.13.1 正确输入版本号即可. 安装cnpm cnpm是淘 ...
- Ubuntu18 mongodb 离线安装
环境 Ubuntu 18 + mongodb 4.0.10 1.下载版本所需库 https://www.mongodb.com/download-center/community https://re ...
- 【代码学习】PYTHON中的静态方法和类方法
一.类方法 是类对象所拥有的方法,需要用修饰器@classmethod来标识其为类方法,对于类方法,第一个参数必须是类对象,一般以cls作为第一个参数(当然可以用其他名称的变量作为其第一个参数,但是大 ...
- 软件版本 Alpha、Beta、Rc
软件版本的周期 α.β.γ 表示软件测试中的三个阶段 α :第一阶段,内部测试使用 β: 第二阶段,消除了大部分不完善的地方,仍可能存在漏洞,一般提供给特定的用户使用 γ: 第三阶段,产品成熟,个别地 ...
- 第三节:Vuejs常用特性2和图书案例
一. 常用特性2 1. 监听器 用watch来响应数据的变化, 一般用于异步或者开销较大的操作, watch 中的属性 一定是data 中 已经存在的数据!!! 当需要监听一个对象的改变时,普通的wa ...
- Win Tomcat8 占用内存过高
1.解压版 找到tomcat/bin/catalina.bat 文件,修改对应参数 2.安装版 windows服务执行的是bin/tomcat.exe.他读取注册表中的值,而不是catalina.ba ...
- Dart语言学习(十四) Dart泛型
什么是泛型? 通俗理解:泛型就是解决 类 接口 方法的复用性.以及对不特定数据类型的支持(类型校验) 如下代码,只能返回string类型的数据 String getData(String value) ...
- Python 的直接赋值、Deepcopy、Copy的区别
直接赋值: 其实就是对象的引用 浅拷贝(copy): 只拷贝符对象,不会拷贝对象内部的子对象 深拷贝(deepcopy): copy 模块的 deepcopy 方法,完全拷贝了父对象及其子对象 有图有 ...
- robot framework 接口post请求需要加headers
说明:当你用RF进行post接口测试时候,那么需要加个headers=Content-Type=application/x-www-form-urlencoded,要不然会请求不成功的.
- LoadRunner的Capture Level
场景:录制loadrunner的web站点 问题:录制的过程中发现除了页面正常的请求外还有些看不懂的请求(包含乱码),脚本如下: web_url("WebTours", " ...