hdoj 2199 Can you solve this equation? 【二分枚举】
题意:给出一个数让你求出等于这个数的x
策略:如题。
由于整个式子是单调递增的。所以能够用二分。
要注意到精度.
代码:
#include <stdio.h>
#include <string.h>
#include <math.h>
#define eps 1e-10
#define f(x) 8*pow(x, 4) + 7*pow(x, 3) + 2*pow(x, 2) + 3*x
int main()
{
int t;
double n;
scanf("%d", &t);
while(t --){
scanf("%lf", &n);
n-=6;
double max = f(100);
if(n<0||n>max){
printf("No solution!\n");
continue;
}
double left, right, mid;
left = 0; right = 100;
while(right-left > 1e-7){ //精度要小于1e-7。
mid = (left+right)/2;
double temp = f(mid);
if(temp < n) left = mid+1e-7;
else right = mid;
}
printf("%0.4lf\n", left);
}
return 0;
}
hdoj 2199 Can you solve this equation? 【二分枚举】的更多相关文章
- 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 == ...
- hdoj 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? 二分 简单题
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 ( ...
- Hdoj 2199.Can you solve this equation? 题解
Problem Description Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solutio ...
- 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?(二分解方程)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/10 ...
- 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 ...
随机推荐
- cocos2d-x动画加速与减速
动画是游戏的必定要素之中的一个,在整个游戏过程中,又有着加速.减速动画的需求.以塔防为样例,布塔的时候希望可以将游戏减速,布好塔后,则希望能将游戏加速:当某个怪被冰冻后,移动速度减缓,而其它怪的移动速 ...
- jsp中生成txt文件
import jxl.Workbook; import jxl.write.Label; import jxl.write.WritableSheet; import jxl.write.Writab ...
- fedora 系统 能够以 root 用户进行登录
1. 切换到root工作环境,因为一下操作必须拥有root权限 [haore147@localhost ~]$ su root 密码: 2. 编辑/etc/pam.d/gdm [root@localh ...
- WKT
WKT - 概念 WKT(Well-known text)是一种文本标记语言,用于表示矢量几何对象.空间参照系统及空间参照系统之间的转换.它的二进制表示方式,亦即WKB(well-known bina ...
- WF4.0(2)----设计工作流
自从做了程序员,发现自己长胖了,而且自己的身体抵抗力也出了问题,最近身体不适,公司工作任务最近也很赶,上次写了WF4.0的简介,这次就工作中工作流设计的几种方式稍微总结一下.设计工作流包括四种方式:流 ...
- C#中Serializable序列化
序列化就是是将对象转换为容易传输的格式的过程,一般情况下转化打流文件,放入内存或者IO文件 中.例如,可以序列化一个对象,然后使用 HTTP 通过 Internet 在客户端和服务器之间传输该对象,或 ...
- 在Android中使用Android Ksoap2调用WebService
一.WebService介绍 WebService是基于SOAP协议可实现web服务器与web服务器之间的通信,因采用SOAP协议传送XML数据具有平台无关性,也是成为解决异构平台之间通信的重要解决方 ...
- ElasticSearch+Kinaba 在Windows下的安装
转自:https://blog.csdn.net/qq_28795681/article/details/79723455 1.下载安装java 2.下载ElasticSearch和Kinaba,并解 ...
- dubbo+maven多模块项目单元测试
基本上就是记录各种报错的解决办法.基本上就是将散落在项目各个模块中的配置文件复制到测试模块中. 目录结构: ——src ——java ——test ——java ——DaoTest.java ——re ...
- [HTML5] Using the focus event to improve navigation accessibility (nextElementSibling)
For a menu item, when we tab onto it, we want this element get 'focus' event, so that the submenu wi ...