poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 13516 | Accepted: 3484 |
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
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
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 题目:可以这样理解,给你一根木杆,夹在某物体之间。现在木杆会受热膨胀,膨胀增长,在两端物体的挤压下就会变弯曲,如上图所示。
从一根直的木杆变到弯曲的木杆,两种状态下,木杆中间位置的高度差是多少?
解法全在上面的图片中! 代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <iostream>
#include <string>
#include <stack>
#include <algorithm>
#define eps 1e-5 using namespace std; int main()
{
// L'=(1+n*C)*L
double L, n, c;
while(scanf("%lf %lf %lf", &L, &n, &c)!=EOF)
{
if(L<0 && n<0 && c<0) break;
double low=0.0;
double high=0.5*L;
double mid;
double s=(1.0+n*c)*L;
double R; while(high-low>eps){
mid=(low+high)/2.0;
R = (4*mid*mid+L*L)/(8*mid);//化简成一次除法 减小精度误差
if(2*R*asin(L/(2*R)) < s)
low=mid;
else
high=mid;
}
printf("%.3lf\n",mid);
}
return 0;
}
poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】的更多相关文章
- POJ 1905 Expanding Rods
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1 ...
- POJ 1905 Expanding Rods(二分)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...
- 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(二分+计算几何)
http://poj.org/problem?id=1905 题意 一根两端固定在两面墙上的杆,受热后变弯曲.求前后两个状态的杆的中点位置的距离 分析 很明显需要推推公式. 由②的限制条件来二分角度, ...
- POJ 1905 Expanding Rods 二分答案几何
题目:http://poj.org/problem?id=1905 恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了. #include < ...
- POJ 1905 Expanding Rods( 二分搜索 )
题意:一个钢棍在两面墙之间,它受热会膨胀成一个圆弧形物体,这个物体长 S = ( 1 + n * C ) * L,现在给出原长 L ,温度改变量 n ,和热膨胀系数 C,求膨胀后先后中点的高度差. 思 ...
- poj 1905 Expanding Rods (数学 计算方法 二分)
题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...
- poj 1905 Expanding Rods 二分
/** 题解晚上写 **/ #include <iostream> #include <math.h> #include <algorithm> #include ...
随机推荐
- Android无线测试之—UiAutomator UiDevice API介绍三
获取坐标与坐标点击 一.坐标相关的知识: 1)手机屏幕坐标:左上角开始到右下角结束 2)DP:设备独立像素,例如320像素显示到640像素上要拉伸一倍 3)Point:代表一个点(x,y),左上角的坐 ...
- 《挑战程序设计竞赛》2.1 穷竭搜索 POJ2718 POJ3187 POJ3050 AOJ0525
POJ2718 Smallest Difference Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6509 Acce ...
- jPage.js分页
jPage.js插件使用文档 这一款插件主要是为了bootstrap原生的分页功能效果不理想而诞生的一款插件. jPage.js代码更新地址为:https://github.com/leslieSie ...
- Xcode生成ipa文件
想到蒲公英应用做分发测试的同学们可以用的到哈 在测试的Device中切换为IOS Device,选择当前项目修改BuildSeting 在code signing Identity中选择证书,没有测试 ...
- 安装和配置jenkins
1.首先准备java环境,安装JDK 2.下载jenkins至Linux服务器 sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkin ...
- 博文分类索引--Python
Python 基础 [python]-- 初识python [python]-- 基本语法.循环 [python]-- 列表 [python]-- 元组.字典 [python]-- 字符串.字符编码与 ...
- ssm框架整合-过程总结(第三次周总结)
本周主要是完成前端界面和后端的整合. 犹豫前后端的工作完成程度不一致,只实现了部分整合. 登录界面. 可能自己最近没有把重心放在短学期的项目上,导致我们工作的总体进度都要比别慢. 虽然我们只是三个人的 ...
- MySQL复制(二):二进制日志、二进制日志的结构和内容
通常只有即将执行完毕的语句才会写入到二进制日志中.但是一些特殊情况:语句附加的信息或直接代替语句被写入. 二进制日志记录的内容 作用:记录数据库中表的更变,用于复制和PITP(即时恢复) 基于语句SB ...
- 通过存储过程运行通过DBLINK的查询语句失败-单个语句成功--ORA-00604
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/q947817003/article/details/24419459 客户遇到个问题,描写叙述例如以 ...
- 脉冲神经网络及有监督学习算法Tempotron
接下来一段时间开启脉冲神经网络模型的探索之旅.脉冲神经网络有更强的生物学基础,尽可能地模拟生物神经元之间的连接和通信方式.其潜在能力较强,值得踏进一步探索. 构建脉冲神经网络模型,至少需要考虑三点:1 ...