Expanding Rods(二分+几何)
来源:互联网 发布:淘宝模特拍摄 下载 编辑:程序博客网 时间:2024/04/29 02:38
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. 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
3
1000 100 0.0001
150 10 0.00006
10 0 0.001
Sample Output
Case 1: 61.3289915
Case 2: 2.2502024857
Case 3: 0
题意:知道L,L2,求h
这里圆弧所对的圆心角的一半,最小0,最大二分之π。对角采用二分法,知道圆心角和弧长可以求出半径。用求出的半径和圆心角可以求出L的长,通过比较求出L的长和L的关系对角二分。求出圆心角在求出H。最开始直接对H二分,应该也能写出来,但是太麻烦了。这个线性关系不好找。
#include<cstdio>#include<math.h>#include<cstring>#include<stdlib.h>#include<algorithm>#define PI acos(-1)using namespace std;double l,n,c,r;int main(){int t,num;scanf("%d",&t);num=1;while(t--){scanf("%lf%lf%lf",&l,&n,&c);printf("Case %d: ",num++);double le=0,ri=PI/2.0,mid;double l2=(1+n*c)*l;while(ri-le>0.0000000001){mid=(le+ri)/2;r=(l/2)/sin(mid);if(r*2*mid>l2)ri=mid;elsele=mid;}printf("%lf\n",r-r*cos(mid));}return 0;}
- Expanding Rods(二分+几何)
- 【LightOJ】1137 - Expanding Rods(二分 & 几何)
- 【Light-oj】-Expanding Rods(二分&几何)
- 【二分+几何】F - Expanding Rods
- poj1905 Expanding Rods(二分+几何)
- POJ 题目1905 Expanding Rods(二分,数学几何)
- Pku oj 1905 Expanding Rods(简单几何加二分)
- Light OJ:1137 Expanding Rods(二分+几何数学)
- POJ1905 Expanding Rods(计算几何推公式+二分)
- POJ 1905 Expanding Rods (二分+计算几何)
- lightoj 1137 Expanding Rods | 二分+几何
- POJ 1905 Expanding Rods(几何+二分)
- POJ 1905-Expanding Rods(二分+计算几何)
- POJ - 1905-Expanding Rods-数论-二分&几何
- POJ 1905 Expanding Rods 几何加二分
- POJ 1905 Expanding Rods几何题,二分
- POJ-1905-Expanding Rods【二分】【计算几何】
- POJ1905 Expanding Rods(二分)
- 你应该知道的 RPC 原理
- post与get的区别
- 冯诺依曼体系结构与哈弗体系结构
- 南阳理工acm 1236 挑战密室
- Storm nimbus 单节点宕机的处理
- Expanding Rods(二分+几何)
- CodeForces 372A Counting Kangaroos is Fun
- 计算机专业名词解释以评论的方式追加
- 数据库视图view
- Apache与Nginx的优缺点比较
- android 版本更新
- c++重载、覆盖、隐藏
- css中具有继承性的属性
- 自动对焦的原理