| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 11782 | Accepted: 3063 |
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. Input
Output
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
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
double l,n,c;
while(cin>>l>>n>>c){
if(l<0&&n<0&&c<0) break;
double down=0.0;
double up=l/2;
double s=(1+n*c)*l;
double h,mid,r;
while(up-down>1e-5){
mid=(up+down)/2;
r=(l*l+4*mid*mid)/(8*mid);
if(2*r*asin(l/(r*2))>s)
up=mid;
else down=mid;
}
h=mid;
printf("%.3lf\n",h);
}
return 0;
}原文地址:http://blog.csdn.net/hyccfy/article/details/41380747