Expanding Rods
Description 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 Source |
[Submit] [Go Back] [Status] [Discuss]
求圆弧的高 网上找的公式 R=(4*H*H+L*L)/(8*H) S=2*R*arcsin(L/(2*R))
给出上界L*1/2下届0 二分枚举求满足式子的H
G++WA好几发 C++秒过 Orz
ACcode:
#include <map> #include <queue> #include <cmath> #include <cstdio> #include <cstring> #include <stdlib.h> #include <iostream> #include <algorithm> #define rd(x) scanf("%d",&x) #define rd2(x,y) scanf("%d%d",&x,&y) #define ll long long int #define maxn 100005 #define mod 1000000007 #define INF 0x3f3f3f3f //int×î´óÖµ #define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;++i) #define MT(x,i) memset(x,i,sizeof(x)) #define PI acos(-1.0) #define E exp(1) #define esp 1e-5 using namespace std; int main(){ double l,n,c,r,s; while(cin>>l>>n>>c){ if(l<0&&n<0&&c<0)break; s=(1+n*c)*l; double up=l*0.5; double down=0; double now; while(up-down>esp){ now=(up+down)/2; r=(4*now*now+l*l)/(8*now); if(2*r*asin(l/(2*r))<s) down=now; else up=now; } printf("%.3lf\n",now); } return 0; } /** 1000 100 0.0001 15000 10 0.00006 10 0 0.001 -1 -1 -1 **/