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

题目大意:
当长度为L的细杆被加热n度时,它扩展到一个新的长度L‘=(1+n*C)*L,其中C是热膨胀系数。当一根细杆安装在两个实心壁上,然后加热时,它就膨胀成一个圆形!!!的节段,原来的杆是节段的弦。你的任务是计算杆中心移位的距离。
→_→
每行输入包含三个非负数:杆的初始长度(毫米)、温度变化(以度计)和材料的热膨胀系数。输入数据保证任何杆都不会膨胀超过其原始长度的一半。最后一行输入包含三个负数,不应该进行处理。

然后输出该木棍的中心位移

题目解析:
几何画出来是酱紫的:

几何关系有

因此在此题中,通过[0,180]进行二分角度,求得h

AC代码如下:

#include<stdio.h>
#include<math.h>
int main()
{double L,LL,C,n,mid,thmin,thmax,h;while(~scanf("%lf %lf %lf",&L,&C,&n))  //输入初始长度,温度以及系数{if(L<0&&C<0&&n<0) break;LL=L*(1+n*C);         //L'thmin=0.0;            //最小角thmax=acos(-1.0);     //大角180°while(thmax-thmin>1e-14) //精度问题要求较高{mid=(thmax+thmin)/2;if(LL*sin(mid)/mid<=L) thmax=mid; //括号内为推导公式else thmin=mid;}printf("%.3f\n",L/2*tan(mid/2));}return 0;
}

POJ - 1905 (几何+二分)相关推荐

  1. A - Expanding Rods POJ - 1905(二分)

    A - Expanding Rods POJ - 1905(二分) 题目 Problem Description When a thin rod of length L is heated n deg ...

  2. poj 2049(二分+spfa判负环)

    poj 2049(二分+spfa判负环) 给你一堆字符串,若字符串x的后两个字符和y的前两个字符相连,那么x可向y连边.问字符串环的平均最小值是多少.1 ≤ n ≤ 100000,有多组数据. 首先根 ...

  3. poj 1905 Expanding Rods(二分)

    题目:http://poj.org/problem?id=1905 题意:看图就明白了... 杆原长为L,受热膨胀弯曲后的长度为 L'=(1+n*C)*L,求中心的移动的距离h: 思路:推出两个公式: ...

  4. [二分查找变形]弯曲的木杆(POJ 1905)

    这题很有意思,除了一般的程序知识,还用了数学的东西.推导了一些公式什么的. 这次用了两种方法做,层层深入,希望能让大家体会到代码的改良过程 第一步: #include <iostream> ...

  5. poj 1905 Expanding Rods 二分

    1 /** 2 题解晚上写 3 **/ 4 #include <iostream> 5 #include <math.h> 6 #include <algorithm&g ...

  6. POJ 3104 Drying 二分

    http://poj.org/problem?id=3104 题目大意: 有n件衣服,每件有ai的水,自然风干每分钟少1,而烘干每分钟少k.求全部弄干的最短时间. 思路: 注意烘干时候没有自然风干. ...

  7. POJ 2456 疯牛(二分+贪心)

    疯牛 时间限制: 1000 ms  |  内存限制: 65535 KB 难度: 4 描述 农夫 John 建造了一座很长的畜栏,它包括N (2 <= N <= 100,000)个隔间,这些 ...

  8. POJ - 2446 Chessboard 二分匹配+建图

    题目链接 题意很简单,是二分匹配的一种常见的题型,问题就在于怎样转换到二分图上来. 首先对对n*m-k正常点进行编号,然后遍历查找每一个正常点的上下左右是否能连接(就是判断另个点是否也是正常的),如果 ...

  9. the 12th UESTC Programming Contest Final Justice is Given by Light (几何+ 二分)

    题目来源: http://acm.uestc.edu.cn/#/problem/show/814 题意:是给你一堆凸包上的点,这些点会形成一个凸多边形,有两个god站在这个多边形上,他们可以释放一个半 ...

最新文章

  1. 编写程序,统计一个长度为2的字符串在另一个字符串中出现的次数
  2. Linux 操作系统原理 — 内存 — Cache 和 Buffer
  3. xStream完美转换XML、JSON
  4. Shutdown SpringBoot App
  5. 运行时库例程-acc_get_num_devices
  6. tomcat关闭后线程依然运行解决办法
  7. 002 Servlet 第一个程序
  8. oracle日期00开头,【原】Oracle中产生 “0000-00-00”格式的日期
  9. python基础数据结构,Python基本数据结构
  10. idea调试jdk源码
  11. 机器学习中的数学——结构化概率模型/图模型
  12. 推送之信鸽推送详解 Think Different
  13. 如何在linux系统下训练tensorflow深度学习模型
  14. JAVA程序员就业面试题大全
  15. 中移动分布式存储超级大单出炉,浪潮等唱主角
  16. 我的世界服务器显示空岛等级,我的世界空岛指令
  17. HTML5、CSS3进阶——渐变背景
  18. 由交通银行卡被盗42万元谈网络应用安全攻防
  19. 轻量化Json开源格式化工具-JSON Formatter
  20. 奇异值分解SVD数学原理及代码(Python)

热门文章

  1. read_exposure_data()
  2. 深入 Hystrix 断路器执行原理
  3. thinkjs查询mysql_记thinkjs数据库add的坑
  4. 2020年安康学院计算机专业代码,2020年陕西所有大学代码四位数 陕西院校代码查询2020四位数...
  5. 微信小程序开发教程:项目七媒体API的运用 课后习题
  6. Oracle -- DBA常用SQL
  7. 发出商品及差异调整方案
  8. 【资料转发分享】基于8086和LCD12864液晶显示仿真设计、基于8086计算器系统仿真设计、基于8086家具房间灯光控制设计-设计资料
  9. HTML5QQ登录cav demo
  10. ssm+Vue计算机毕业设计智慧工地管理系统(程序+LW文档)