二分
2016-05-01 10:09
441 查看
https://www.bnuoj.com/v3/contest_show.php?cid=7814#problem/B
#include<iostream>//c++
#include<cmath>//数学公式
#include<cstdlib>//malloc
#include<cstring>
#include<string>
#include<cstdio>//输入输出
#include<algorithm>//快排
#include<queue>//队列
#include<functional>//优先队列
#include<stack>//栈
#include<vector>//容器
#include<map>//地图 if continue
typedef long long ll;
const int N=30;
const double inf=1e-8;
using namespace std;
double x,y,c,l,r,mid;
double get(double z)
{
return 1-c/sqrt(x*x-z*z)-c/sqrt(y*y-z*z);
}
int main()
{
int i,j,m,z,n,k,ans,tmp;
while(~scanf("%lf%lf%lf",&x,&y,&c))
{
l=0;
if(x<y) r=x;
else r=y;
while(r-l>inf)
{
mid=(l+r)/2;
if(get(mid)>0) l=mid;
else r=mid;
}
printf("%.3lf\n",mid);
}
return 0;
}
#include<iostream>//c++
#include<cmath>//数学公式
#include<cstdlib>//malloc
#include<cstring>
#include<string>
#include<cstdio>//输入输出
#include<algorithm>//快排
#include<queue>//队列
#include<functional>//优先队列
#include<stack>//栈
#include<vector>//容器
#include<map>//地图 if continue
typedef long long ll;
const int N=30;
const double inf=1e-8;
using namespace std;
double x,y,c,l,r,mid;
double get(double z)
{
return 1-c/sqrt(x*x-z*z)-c/sqrt(y*y-z*z);
}
int main()
{
int i,j,m,z,n,k,ans,tmp;
while(~scanf("%lf%lf%lf",&x,&y,&c))
{
l=0;
if(x<y) r=x;
else r=y;
while(r-l>inf)
{
mid=(l+r)/2;
if(get(mid)>0) l=mid;
else r=mid;
}
printf("%.3lf\n",mid);
}
return 0;
}
相关文章推荐
- ajax的参数详解
- XAMPP 虚拟主机设置
- CentOS 6.3下rsync服务器的安装与配置
- 数据挖掘-聚类分析
- 【SVN】VS2015和SVN合作
- centOS中如何修改运行级别!
- 第 22 章 CSS3 渐变效果
- JavaScript中的继承之类继承
- spring cloud: Hystrix断路器(熔断器)
- ServletConfig与ServletContext
- 影响Spark输出RDD分区的操作函数
- 深度学习之一:CNN初始
- BestCoder Round #82 (div.2) -ztr loves lucky numbers(BFS)
- R语言:特殊数据类型S4
- JavaScript函数
- 数据结构之链表学习心得
- android中xml tools属性详解
- MySQL 常用基础命令
- 简单链表的建立
- SpringAOP Demo