POJ 1905 Expanding Rods(二分)
Expanding Rods
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 20224 Accepted: 5412
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
The input contains multiple lines. Each line of input contains three non-negative numbers: the initial lenth of the rod in millimeters, the temperature change in degrees and the coefficient of heat expansion of the material. 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
For each line of input, output one line with the displacement of the center of the rod in millimeters with 3 digits of precision.
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
Waterloo local 2004.06.12
二分,看到网上都是asin acos 做的,其实只要有一个关系式,就能进行二分,二分是一种思想,别要人云亦云。
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define esp 1e-8
int main()
{
double len,c,lv,h,up,lo,r;
while(scanf("%lf%lf%lf",&len,&c,&lv)==3&&!(len==-1))
{
double len2=(1+c*lv)*len;
up=len/2.0;
lo=0.0;
while(up-lo>esp){
h=(up+lo)/2.0;
r=(len*len+4*h*h)/8/h;
// cout<<len2/2.0/r<<" "<<asin(len/2.0/r)<<" "<<up<<" "<<lo<<" "<<h<<endl;
if((len2/2.0/r)>asin(len/2.0/r)) lo=h;
else up=h;
}
printf("%.3f\n",h);
}
return 0;
}
POJ 1905 Expanding Rods(二分)的更多相关文章
- 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 ...
- poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
...
- POJ 1905 Expanding Rods
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1 ...
- POJ - 1905 Expanding Rods(二分+计算几何)
http://poj.org/problem?id=1905 题意 一根两端固定在两面墙上的杆,受热后变弯曲.求前后两个状态的杆的中点位置的距离 分析 很明显需要推推公式. 由②的限制条件来二分角度, ...
- poj 1905 Expanding Rods (数学 计算方法 二分)
题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...
- 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,求膨胀后先后中点的高度差. 思 ...
随机推荐
- Tkinter布局管理器
Layout management in Tkinter 原英文教程地址:zetcode.com In this part of the Tkinter tutorial, we introduce ...
- 7L-双线链表实现
链表是基本的数据结构,尤其双向链表在应用中最为常见,LinkedList 就实现了双向链表.今天我们一起手写一个双向链表. 文中涉及的代码可访问 GitHub:https://github.com/U ...
- 2017蓝桥杯杨辉三角(C++C组)
题目: 杨辉三角也叫帕斯卡三角,在很多数量关系中可以看到,十分重要.第0行: 1第1行: 1 1第2行: 1 2 1第3行: 1 3 ...
- Pytest系列(16)- 分布式测试插件之pytest-xdist的详细使用
如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 平常我们功能测试用例非常多时 ...
- Spring 中 用 ${xxx} 读取properties文件的说明
properties 如果在 spring 中通过 PropertyPlaceholderConfigurer 加载,当spring 中需要 用到 properties 中的一些 key 和value ...
- Spring温习(1)--最基础的示例
Spring温习(1)--最基础的示例 博客分类: 框架-Spring专栏 SpringXMLBeanWebDAO 从现在开始,我将从Spring为起点,逐步复习几大框架各方面的知识,以便今后查看使用 ...
- 化繁为简,弱监督目标定位领域的新SOTA - 伪监督目标定位方法(PSOL) | CVPR 2020
论文提出伪监督目标定位方法(PSOL)来解决目前弱监督目标定位方法的问题,该方法将定位与分类分开成两个独立的网络,然后在训练集上使用Deep descriptor transformation(DDT ...
- Python—一个简单搜索引擎索引库
因为课业要求,搭建一个简单的搜索引擎,找了一些相关资料并进行了部分优化(坑有点多) 一.数据 数据是网络上爬取的旅游相关的攻略页面 这个是travels表,在索引中主要用到id和url两个字段. 页面 ...
- A Bug's Life POJ - 2492 (种类或带权并查集)
这个题目的写法有很多,用二分图染色也可以写,思路很好想,这里我们用关于并查集的两种写法来做. 题目大意:输入x,y表示x和y交配,然后判断是否有同性恋. 1 带权并查集: 我们可以用边的权值来表示一种 ...
- linux下五种查找命令
我们经常需要在系统中查找一个文件或者命令,那么在Linux系统中如何快速定位和精确查找它呢?下面总结了五个基础命令·分别是which.whereis.type.locate.find. 一 whi ...