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;
}

最新文章

  1. cxf ServerFactoryBean 生成基于soap1.2的WebServices
  2. 玩转Docker之安装篇(二)
  3. C++ list的基本操作和使用
  4. Memcached——分布式缓存
  5. PAT1038. Recover the Smallest Number
  6. 解决TableView / ScrollView上的Menu问题(1滑出View区域还可点击2导致点击menu后View不能滑动)
  7. Java中的Enum枚举类型总结
  8. &lt;转&gt;Windows 各种计时函数总结
  9. Win7下IE8无法打开https类型的网站解决方法笔记
  10. java 集合专练
  11. 获取客户端IP地址定位城市信息
  12. Telepro工具注册码
  13. Springboot与Mybatis整合
  14. 微信官方团队放出了UI库,看来以后前端还要学WeChatUI了,哈哈
  15. JavaScript中对象数组 作业
  16. python全栈开发day64-模板-变量和(.)的使用,filters和自定义filter
  17. AngularJS学习笔记(二)
  18. 关于H5在移动端架构的优化设计总结
  19. .NET Core使用Quartz执行调度任务进阶(转)
  20. 使用Maven创建(eclipse)Java项目

热门文章

  1. Android Visibility控件显示和隐藏
  2. MySQL入门,第四部分,学会创建、删除表
  3. .net 后台调用前台JS函数
  4. git处理fork的个人库代码与远程项目库待代码同步与合并
  5. 记一次Windows蓝屏分析
  6. 怎么自定义DataGridViewColumn(日期列,C#)
  7. 在Python中该如何实现Java的重写与重载
  8. Python中的可视化神器!你知道是啥吗?没错就是pyecharts!
  9. 数值计算方法实验之newton多项式插值 (Python 代码)
  10. fashion_mnist多分类训练,两种模型的保存与加载