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

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

  1. 1000 100 0.0001
  2. 15000 10 0.00006
  3. 10 0 0.001
  4. -1 -1 -1

Sample Output

  1. 61.329
  2. 225.020
  3. 0.000

Source

Waterloo local 2004.06.12



写了三个公式acos过不了,后来金巨说asin和acos产生的误差atan要大

  1. #include <set>
  2. #include <map>
  3. #include <list>
  4. #include <stack>
  5. #include <cmath>
  6. #include <vector>
  7. #include <queue>
  8. #include <string>
  9. #include <cstdio>
  10. #include <cstdlib>
  11. #include <cstring>
  12. #include <iostream>
  13. #include <algorithm>
  14. #define PI acos(-1.0)
  15. using namespace std;
  16.  
  17. typedef long long LL;
  18.  
  19. const int MAX = 50010;
  20.  
  21. const double eps = 1e-5;
  22.  
  23. double l,c,n;
  24. double ll;
  25. bool Judge(double mid)
  26. {
  27. double r=(l*l+4*mid*mid)/(8*mid);
  28. double dis=2*r*asin(l/(2*r));
  29. //atan(l/(2*(r-mid)));
  30. if(dis<ll)
  31. {
  32. return true;
  33. }
  34. else
  35. {
  36. return false;
  37. }
  38. }
  39.  
  40. int main()
  41. {
  42. while(scanf("%lf %lf %lf",&l,&n,&c))
  43. {
  44. if(l==-1&&c==-1&&n==-1)
  45. {
  46. break;
  47. }
  48. ll=(1+n*c)*l;
  49. double L=0;
  50. double R=l/2;
  51. double ans=0;
  52. while(R-L>eps)
  53. {
  54. double mid = (L+R)/2;
  55. if(Judge(mid))
  56. {
  57. ans=mid;
  58. L=mid;
  59. }
  60. else
  61. {
  62. R=mid;
  63. }
  64. }
  65. printf("%.3f\n",ans);
  66. }
  67. return 0;
  68. }

Expanding Rods(二分POJ1905)的更多相关文章

  1. 二分法 (UVA10668 Expanding Rods)(二分+几何)

    转载请注明出处:優YoU http://user.qzone.qq.com/289065406/blog/1301845324 大致题意: 一根两端固定在两面墙上的杆 受热弯曲后变弯曲.求前后两个状态 ...

  2. Expanding Rods(二分)

    Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10287   Accepted: 2615 Description When ...

  3. POJ 1905 Expanding Rods 二分答案几何

    题目:http://poj.org/problem?id=1905 恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了. #include < ...

  4. poj 1905 Expanding Rods 二分

    /** 题解晚上写 **/ #include <iostream> #include <math.h> #include <algorithm> #include ...

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

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

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

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

  7. D - Expanding Rods POJ - 1905(二分)

    D - Expanding Rods POJ - 1905 When a thin rod of length L is heated n degrees, it expands to a new l ...

  8. POJ 1905 Expanding Rods(二分)

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

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

                                                                                                         ...

随机推荐

  1. JAVA字符串的GZIP压缩解压缩

    package com.gzip; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import ...

  2. Lintcode: Count of Smaller Number

    Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 1 ...

  3. Servlet 基础认识 使用

    参考书<JSP Web 开发案例教程> 在jsp项目中的src文件下面创建HelloServletTest.java,代码如下,注意src的包名,我的包名是zhbit.com packag ...

  4. HDU 1890 区间反转

    http://acm.hdu.edu.cn/showproblem.php?pid=1890 Robotic Sort Problem Description Somewhere deep in th ...

  5. 事务——sql server中的事务应用举例

    sql中事务只针对一个update,delete,insert语句,如果一段程序中有超过一个这样的语句,就需要每个都判断是否出错,否则就会出现若干我们不希望的情形出现,举例如下(表结构见最后): 1, ...

  6. java经典小算法

    package com.shb.java; public class Demo4 { /**时间有限 先不写文字了 自己随便敲的 * @param args * @author shaobn */ p ...

  7. sql 存储过程参数是表类型,数据库中如何调用

    DECLARE @NEW_STUDENT as [CancelLendersContent] INSERT @NEW_STUDENT VALUES (0,0,0,'12345678912','张三', ...

  8. 最懂中文的H5前端框架amazeUI

    Amaze UI 是一个轻量级(所有 CSS 和 JS gzip 后 100 kB 左右)的前端框架, 基于开源社区流行前端框架编写 amazeUI的网址:http://amazeui.org/get ...

  9. hadoop文件系统FileSystem详解 转自http://hi.baidu.com/270460591/item/0efacd8accb7a1d7ef083d05

    Hadoop文件系统 基本的文件系统命令操作, 通过hadoop fs -help可以获取所有的命令的详细帮助文件. Java抽象类org.apache.hadoop.fs.FileSystem定义了 ...

  10. spring的定时任务

    maven中引入quartz的jar包依赖 单纯针对时间的设置规则org.springframework.scheduling.quartz.CronTriggerBean允许你更精确地控制任务的运行 ...