HDU 2199 Can you solve this equation(二分答案)
Can you solve this equation?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 27728 Accepted Submission(s): 11717
solution between 0 and 100;
Now please try your lucky.
number of test cases. Then T lines follow, each line has a real number Y
(fabs(Y) <= 1e10);
decimal places),which is the solution of the equation,or “No solution!”,if
there is no solution for the equation between 0 and 100.
【题意】
在[0,100]内找一个方程的实数解。
【分析】
求导易得函数单增,只需二分即可。
注意精度!
【代码】
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int N=1e5+5;
int n;double Y;
inline double f(double x){
return 8*x*x*x*x+7*x*x*x+2*x*x+3*x+6;
}
int main(){
for(n=read();n--;){
scanf("%lf",&Y);
if(Y<f(0)||Y>f(100)){puts("No solution!");continue;}
double l=0,r=100,mid,ans;
while(r-l>1e-6){
mid=(l+r)/2.0;
if(Y-f(mid)<=1e-5){
ans=mid;
r=mid;
}
else{
l=mid;
}
}
printf("%.4lf\n",ans);
}
return 0;
}
HDU 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 == ...
- 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 ( ...
- 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 ...
- HDU 2199 Can you solve this equation?【二分查找】
解题思路:给出一个方程 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,求方程的解. 首先判断方程是否有解,因为该函数在实数范围内是连续的,所以只需使y的值满足f(0)< ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- Vue页面跳转$router.push 的用法
vue2.0在使用的过程中, .vue文件之间的跳转,在template中的常见写法是: <router-link to="/miniCard/statement/horizon&qu ...
- 安装PHP5 PHP7
安装 PHP5 PHP官网www.php.net • 当前主流版本为5./7.1 • cd /usr/local/src/ • wget http://cn2.php.net/distribution ...
- 解决错误:“废弃 document 元素之后的内容”——HTML5新特性,局部样式表
最近正在学习angularjs,不过本文和angularjs没多大关系.在学习使用route和ng-view使用模版之后,发现view装载之后,firefox都会报个错误“废弃 document 元素 ...
- Oracle性能调整ASH,AWR,ADDM
ASH (Active Session History)ASH以V$SESSION为基础,每秒采样一次,记录活动会话等待的事件.不活动的会话不会采样,采样工作由新引入的后台进程MMNL来完成.ASH ...
- 《倾国倾城》全套源代码:client+服务端+资源,歧视复制帖子
郝萌主倾心贡献,尊重作者的劳动成果,请勿转载. 假设文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额任意.重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源代码下载:点我传送 游戏官方下 ...
- Activiti 5.1.4最佳实践
1.简单介绍 Activiti是一个开源的工作流引擎,它实现了BPMN 2.0规范,可以发布设计好的流程定义,并通过api进行流程调度. Activiti 作为一个遵从 Apache 许可的工作流和业 ...
- xml文件的序列化示例
1.创建activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/andr ...
- 指定cmd窗口或tomcat运行窗口的名称
1. 指定cmd窗口运行时名称 1)直接执行命令:title 窗口名称 2)bat文件中直接加上命令:title 窗口名称 例子: title test_ v1 java -jar -Dfile.en ...
- [PyCharm] 设置自动启动时自动打开项目
设置启动PyCharm时自动打开(或不打开)上次进行的项目: 选择 “Settings - General - Reopen last project on startup”,勾选该选项则启动时自动打 ...
- DRBD架构详解(原创)
DRBD概述Distributed Replicated Block Device(DRBD)是一种基于软件的,无共享,复制的存储解决方案,在服务器之间的对块设备(硬盘,分区,逻辑卷等)进行镜像.DR ...