Expanding Rods(二分POJ1905)
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 13688 | Accepted: 3527 |
Description

When a thin rod is mounted on two solid walls and then heated, it expands and takes the shape of a circular segment, the original rod being the chord of the segment.
Your task is to compute the distance by which the center of the rod is displaced.
Input
data guarantee that no rod expands by more than one half of its original length. The last line of input contains three negative numbers and it should not be processed.
Output
Sample Input
1000 100 0.0001
15000 10 0.00006
10 0 0.001
-1 -1 -1
Sample Output
61.329
225.020
0.000
Source
写了三个公式acos过不了,后来金巨说asin和acos产生的误差atan要大
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define PI acos(-1.0)
using namespace std; typedef long long LL; const int MAX = 50010; const double eps = 1e-5; double l,c,n;
double ll;
bool Judge(double mid)
{
double r=(l*l+4*mid*mid)/(8*mid);
double dis=2*r*asin(l/(2*r));
//atan(l/(2*(r-mid)));
if(dis<ll)
{
return true;
}
else
{
return false;
}
} int main()
{
while(scanf("%lf %lf %lf",&l,&n,&c))
{
if(l==-1&&c==-1&&n==-1)
{
break;
}
ll=(1+n*c)*l;
double L=0;
double R=l/2;
double ans=0;
while(R-L>eps)
{
double mid = (L+R)/2;
if(Judge(mid))
{
ans=mid;
L=mid;
}
else
{
R=mid;
}
}
printf("%.3f\n",ans);
}
return 0;
}
Expanding Rods(二分POJ1905)的更多相关文章
- 二分法 (UVA10668 Expanding Rods)(二分+几何)
转载请注明出处:優YoU http://user.qzone.qq.com/289065406/blog/1301845324 大致题意: 一根两端固定在两面墙上的杆 受热弯曲后变弯曲.求前后两个状态 ...
- Expanding Rods(二分)
Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 10287 Accepted: 2615 Description When ...
- POJ 1905 Expanding Rods 二分答案几何
题目:http://poj.org/problem?id=1905 恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了. #include < ...
- poj 1905 Expanding Rods 二分
/** 题解晚上写 **/ #include <iostream> #include <math.h> #include <algorithm> #include ...
- UVA 10668 - Expanding Rods(数学+二分)
UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...
- POJ 1905:Expanding Rods 求函数的二分
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13780 Accepted: 3563 D ...
- D - Expanding Rods POJ - 1905(二分)
D - Expanding Rods POJ - 1905 When a thin rod of length L is heated n degrees, it expands to a new l ...
- POJ 1905 Expanding Rods(二分)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...
- poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
...
随机推荐
- 解决eclipse svn插件 的lock问题
org.tigris.subversion.javahl.ClientException: Attemptedto lock an already-locked dir异常解决方法 myeclipse ...
- decimal类型保留两位小数
oj.PriceTop =Math.Round(Convert.ToDecimal(reader["PriceTop"]),2);
- 配置DruidDataSource参考(com.alibaba.druid.pool.DruidDataSource)
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-met ...
- Eclipse 文本显示行号
- 如何在OneNote2013中粘贴高亮的代码
有的时候想在OneNote粘贴代码,但是直接复制粘贴进去的代码没有高亮,下面有一个办法让自己的代码在OneNote里面更加完整美观. 工具/原料 Notepad++ word2013 OneNote2 ...
- php初探
1.php中的连接符.可以连接多个字符串,相当于java中的+ 2.echo必须与后面的输出内容有至少一个空格 3.php编程中每个结尾都需要添加分号
- 每天一个shell知识--数组
1.shell中数组的定义: 数组名=(value value1 value2 ) 也可以单独的设定数组的分量: arrayL[0]=value arrayL[1]=value1 2.${arrayL ...
- 。。。Hibernate注解配置的注意事项。。。
今天本来打算录视频的,突然遇到一个拦路虎,Hibernate注解配置,有一个注意点:要么都在属性上面注解配置,要么都在getXX()方法上面用注解配置,要不然就会报错: Caused by: org. ...
- kafka监控工具kafkaOffsetMoniter的使用
简介 KafkaOffsetMonitor是由Kafka开源社区提供的一款Web管理界面,用来实时监控Kafka的Consumer以及Partition中的Offset,可以在web界面直观的看到每个 ...
- struts拦截器
struts中的拦截器相当于过滤器的作用 一在struts.xml中配置拦截器或拦截器栈 <interceptors>!--全部的拦截器 <interceptor name=&quo ...