D - Expanding Rods POJ - 1905

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
Sponsor

思路

  • 利用数学中的 几何等式 建立方程,利用二分答案 来一个一个进行 尝试答案

题解

//Memory Time
//244K 0MS #include<iostream>
#include<math.h>
#include<iomanip>
using namespace std; const double esp=1e-5; //最低精度限制 int main(void)
{
//freopen("A.txt","r",stdin);
double L,n,c,s; //L:杆长 ,n:温度改变度 , c:热力系数 ,s:延展后的杆长(弧长)
double h; //延展后的杆中心 到 延展前杆中心的距离
double r; //s所在圆的半径 while(cin>>L>>n>>c)
{
if(L<0 && n<0 && c<0)
break; double low=0.0; //下界
double high=0.5*L; // 0 <= h < 1/2L (1/2L并不是h的最小上界,这里做一个范围扩展是为了方便处理数据) double mid;
s=(1+n*c)*L;
while(high-low>esp) //由于都是double,不能用low<high,否则会陷入死循环
{ //必须限制low与high的精度差
mid=(low+high)/2;
r=(4*mid*mid+L*L)/(8*mid); if( 2*r*asin(L/(2*r)) < s ) //h偏小
low=mid;
else //h偏大
high=mid;
}
h=mid; cout<<fixed<<setprecision(3)<<h<<endl;
}
return 0;
}

D - Expanding Rods POJ - 1905(二分)的更多相关文章

  1. Expanding Rods POJ 1905 二分

    Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17050   Accepted: 4503 Description When ...

  2. 【二分答案】Expanding Rods POJ 1905

    题目链接:http://poj.org/problem?id=1905 题目大意:原长度为L的线段因受热膨胀为一段弧,线段L.弧长L'.温度n.膨胀率c满足L' =(1+n/c)*L;求线段的中点移动 ...

  3. poj 1905 Expanding Rods (数学 计算方法 二分)

    题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...

  4. POJ 1905:Expanding Rods 求函数的二分

    Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13780   Accepted: 3563 D ...

  5. POJ 1905 Expanding Rods(二分)

    Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...

  6. poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】

                                                                                                         ...

  7. POJ 1905 Expanding Rods

                           Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1 ...

  8. UVA 10668 - Expanding Rods(数学+二分)

    UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...

  9. Expanding Rods(二分POJ1905)

    Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13688   Accepted: 3527 D ...

随机推荐

  1. 跟我猜Spring-boot:依赖注入

    依赖注入 引&目标 本篇是<跟我猜Spring-Boot>系列的第二篇(Oh,我竟然已经写了10篇了,真不容易). 在上一篇中,我们实现了Bean的创建,但是仅仅是创建而已,并没有 ...

  2. 【,NetCore】WebApi使用统一时间格式

    1.在Startup中配置统一时间格式 services.AddMvc() .AddJsonOptions(options => { //配置时间序列化格式 options.Serializer ...

  3. 第一个Hystrix程序 Hystrix 一

    1.导入jar包 <dependencies> <dependency> <groupId>com.netflix.hystrix</groupId> ...

  4. hadoop HDFS完全分布式搭建

    1.准备阶段 准备好两台虚拟机(安装好hadoop,见:https://www.cnblogs.com/cjq10029/p/12336446.html),计划: IP 主机名 192.168.3.7 ...

  5. django 博客搭建

    comment1.安装django pip install django 2.创建项目 django-admin startproject mysite 3.在mysite文件夹下创建app pyth ...

  6. scrapy启动

    创建项目 在开始爬取之前,您必须创建一个新的Scrapy项目. 进入您打算存储代码的目录中,运行下列命令: scrapy startproject scrapytest 第一种scrapy gensp ...

  7. C++ 重载关系操作符

    #include <iostream> using namespace std; class AAA { public: AAA() //默认构造 { } AAA(int id, stri ...

  8. 建议20:建议通过Function扩展类型

    JavaScript允许为语言的基本数据类型定义方法.通过Object.prototype添加原型方法,该方法可被所有的对象,.这样的方法对函数,数组,字符串,数字,正则表达式和布尔值都适用.例如,通 ...

  9. 会话存储sessionStorage

    会话存储的工作方式和本地存储的工作方式很接近,不同之处在于数据是各个浏览器上下文私有的,会在文档被关闭时移除(注意是被关闭时才移除,刷新是不会移除的).我们通过全局sessionStorage访问会话 ...

  10. Java学习笔记(3)——有关异常

    异常处理: try { }catch(ExceptionType0 e) { }catch(ExceptionType1 e) { }.....finally { } 有四种情况不执行finally语 ...