POJ 1905 Expanding Rods
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 10187 | Accepted: 2593 |
Description
When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. 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
Output
Sample Input
Sample Output
61.329
225.020
0.000
Source
我们要求的是下图中的b,显然b的取值范围是[0,L/2]。对于每一个b,我们可以求出在已知弦L的情况下的半径R,从而可以求出此半径R和弦L下对应的圆弧的长度L0。经过与公式计算出来的L1进行对比,调整b的大小。经过观察,发现b越大,L0也就越大。所以如果L0>L1,应使b减小(right=mid-e),以减少L0。相反,当L0<L1的时候,应该让b增大(left=mid+e),以增大L0。
附注:求半径的方法是根据a,b,d,先求出h,然后求出R。接着根据圆心角和半径,求出圆弧的长度。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const double eps=1e-; double l,l0,l00; double get00(double b)
{
double a=l/.;
double d=sqrt(a*a+b*b);
double h=d*a/b;
double R=sqrt(h*h+d*d)/.;
double alpha=atan(b/a);
return *alpha*R;
} int main()
{
double n,c;
while(cin>>l>>n>>c)
{
if(l<&&n<&&c<) break;
l0=(.+n*c)*l;
if(fabs(l0-l)<eps)
{
printf("0.000\n");
continue;
}
double low=,high=l/.,mid,ans;
while(low<high)
{
mid=(low+high)/.;
l00=get00(mid);
if(fabs(l00-l0)<eps)
{
ans=mid; break;
}
else if(l00>l0)
high=mid;
else
low=mid;
}
printf("%.3lf\n",ans);
}
return ;
}
POJ 1905 Expanding Rods的更多相关文章
- poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
...
- POJ 1905 Expanding Rods(二分)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...
- POJ 1905 Expanding Rods 二分答案几何
题目:http://poj.org/problem?id=1905 恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了. #include < ...
- POJ - 1905 Expanding Rods(二分+计算几何)
http://poj.org/problem?id=1905 题意 一根两端固定在两面墙上的杆,受热后变弯曲.求前后两个状态的杆的中点位置的距离 分析 很明显需要推推公式. 由②的限制条件来二分角度, ...
- poj 1905 Expanding Rods (数学 计算方法 二分)
题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...
- poj 1905 Expanding Rods 二分
/** 题解晚上写 **/ #include <iostream> #include <math.h> #include <algorithm> #include ...
- POJ 1905 Expanding Rods 木棍膨胀
描述 当长度为L的一根细木棍的温度升高n度,它会膨胀到新的长度L'=(1+n*C)*L,其中C是热膨胀系数. 当一根细木棍被嵌在两堵墙之间被加热,它将膨胀形成弓形的弧,而这个弓形的弦恰好是未加热前木棍 ...
- POJ 1905 Expanding Rods (求直杆弯曲拱起的高度)(二分法,相交弦定理)
Description When a thin rod of length L is heated n degrees, it expands to a new length L' = (1+n*C) ...
- POJ 1905 Expanding Rods( 二分搜索 )
题意:一个钢棍在两面墙之间,它受热会膨胀成一个圆弧形物体,这个物体长 S = ( 1 + n * C ) * L,现在给出原长 L ,温度改变量 n ,和热膨胀系数 C,求膨胀后先后中点的高度差. 思 ...
随机推荐
- nginx location在配置中的优先级
location表达式类型 ~ 表示执行一个正则匹配,区分大小写~* 表示执行一个正则匹配,不区分大小写^~ 表示普通字符匹配.使用前缀匹配.如果匹配成功,则不再匹配其他location.= 进行普通 ...
- Error: cannot find a valid baseurl for repo: rpmfusion-free 解决办法
今天在玩CentOS的时候出现了: Error: cannot find a valid baseurl for repo: rpmfusion-free 这个问题真到好恶心啊,以前一直使用到是ubu ...
- Python: sort,sorted,OrderedDict的用法
Python: sort,sorted,OrderedDict的用法 from http://stqdd.com/archives/427 by 莫亚菜 python对容器内数据的排序有两种,一种是容 ...
- Yocto开发笔记之《Makefile编写》(QQ交流群:519230208)
开了一个交流群,欢迎爱好者和开发者一起交流,转载请注明出处. QQ群:519230208,为避免广告骚扰,申请时请注明 “开发者” 字样 =============================== ...
- e_msg_c_as_register_req-注册存储过程
TOP:BEGIN #Routine body goes here... IF EXISTS ( SELECT * FROM `global_account` WHERE `plantform_id` ...
- NLTK中文语料库sinica_treebank
http://www.hankcs.com/program/python/nltk-chinese-corpus-sinica_treebank.html NLTK包含Sinica (中央研究院)提供 ...
- Runtime类
Runtime类表示运行时的操作类,是一个封装了JVM进程的类,每一个JVM都对应着一个Runtime类的实例,此实例由JVM运行时为其实例化. //========================= ...
- 菜鸟疑问之新建网站与新建web应用程序区别
学习asp.net一定少不了这困惑:新建网站与新建web应用程序有什么区别? 新建web应用程序 新建网站 呵呵,其实从名字看一个是webApplication,一个是webSite.名字不同罢了? ...
- 如何使Python完美升级到新版本
这里提供一种解决的方法 (加上一句话,发现一个新问题:这种方法yum update 后,需要将/usr/bin下的python文件删除,然后执行: # ln -s /usr/local/python2 ...
- C#和SQL实现的字符串相似度计算代码分享
http://www.jb51.net/article/55941.htm C#实现: 复制代码 代码如下: #region 计算字符串相似度 /// <summary> ...