1137 - Expanding Rods
Time Limit: 0.5 second(s) Memory Limit: 32 MB

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. That means you have to calculate h as in the picture.

Input

Input starts with an integer T (≤ 20), denoting the number of test cases.

Each case contains three non-negative real numbers: the initial length of the rod in millimeters L, the temperature change in degrees n and the coefficient of heat expansion of the material C. Input data guarantee that no rod expands by more than one half of its original length. All the numbers will be between 0 and 1000 and there can be at most 5 digits after the decimal point.

Output

For each case, print the case number and the displacement of the center of the rod in single line. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

3

1000 100 0.0001

150 10 0.00006

10 0 0.001

Case 1: 61.3289915

Case 2: 2.2502024857

Case 3: 0


SPECIAL THANKS: JANE ALAM JAN (DESCRIPTION, SOLUTION, DATASET, PICTURES)

思路:L' = p*r ——p为弧度

r = (L/2)/sin(p/2)

然后公式可以化为 (2×L') /L=(p)/sin(p/2);

然后右边求导可知道右边随p单调增,然后二分p即可。

 1 #include<stdio.h>
2 #include<algorithm>
3 #include<iostream>
4 #include<string.h>
5 #include<queue>
6 #include<stack>
7 #include<set>
8 #include<math.h>
9 using namespace std;
10 typedef long long LL;
11 double pi=acos(-1);
12 int main(void)
13 {
14 int i,j,k;
15 scanf("%d",&k);
16 int s;
17 double L ,n,c;
18 for(s=1; s<=k; s++)
19 {
20 scanf("%lf %lf %lf",&L,&n,&c);
21 double l=0;
22 double r=2*pi;
23 int ans=0;
24 double ll=(1+n*c)*L;
25 while(ans<=100)
26 {
27 double mid=(l+r)/2;
28 double ac=2*ll*sin(1.0*mid/2);
29 double ak=L*mid;
30 if(ac>=ak)
31 {
32 l=mid;
33 }
34 else r=mid;
35 ans++;
36 }
37 double rr=(1.0*L/2)/(sin(1.0*r/2));
38 double hh=rr*cos(1.0*r/2);
39 double h=rr-hh;
40 printf("Case %d:",s);
41 printf(" %.6f\n",h);
42 }
43 return 0;
44 }

最新文章

  1. virtualenv 安装使用
  2. 在SqlServer中使用Try Catch(转)
  3. hadoop NameNode 手动HA
  4. 【Mac】Mac键盘实现Home, End, Page UP, Page DOWN
  5. X/Open DTP——分布式事务模型
  6. 【Database】MongoDB教程
  7. HDU 1248 寒冰王座(全然背包:入门题)
  8. Windows Shell(外壳)编程相关
  9. .net做的exe和electron做的exe之间的通信问题
  10. JaveScript变量的简介及其变量的简单使用(JS知识点归纳一)
  11. spring boot热部署
  12. Linux socket 类封装 (面向对象方法)
  13. button 和input 的区别及在表单form中的用法
  14. 中国四大骨干网与十大ISP服务商
  15. vue百度地图插件
  16. SharePoint CU、Hotfix和SP版本的区别
  17. python 文件读写方式
  18. Jquery DataTable基本使用
  19. nginx 代理tcp长连接短连接配置
  20. xcopy-参数详解

热门文章

  1. Go 性能提升tips--边界检查
  2. js获取中国省市区,省市筛选、省市、省市筛选联动。【C#】【js】
  3. c#GridView
  4. Shell 打印文件的最后5行
  5. mysql数据定义语言DDL
  6. ceph安装部署
  7. vim一键整理代码命令
  8. 实时数据同步inotify+rsync
  9. liunx 安装ActiveMQ 及 spring boot 初步整合 activemq
  10. springmvc中拦截器的定义和配置