您的位置:首页 > 其它

POJ 1905 Expanding Rods 几何加二分

2015-09-24 14:14 609 查看
Expanding Rods

Time Limit: 1000MSMemory Limit: 30000K
Total Submissions: 13735Accepted: 3550
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
1000 100 0.0001
15000 10 0.00006
10 0 0.001
-1 -1 -1

Sample Output
61.329
225.020
0.000

Source

Waterloo local 2004.06.12
[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**/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: