poj 1905 Expanding Rods

Expanding Rods
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 15096 Accepted: 4009

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

题意:某种材料制作的长杆,现在因为温度升高而出现隆起,现在问你隆起的高度是多少。

我们假设隆起的高度的是h,则h和圆弧的半径r以及圆弧的长度(次l)之间的关系有:


第一个勾股定理就可以出来,第二个根据弧长等于弧度乘上半径就可以出来。

然后我们二分查找答案,确保我们求得的l和题目所给的l1的值相差到某个级位就可以。

范围就是0~h/2辣

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f;
const int MAXN=50000+10;
double eps=1e-5;

int main()
{
    double l,n,c;
    while(~scanf("%lf%lf%lf",&l,&n,&c))
    {
        if(l<0&&n<0&&c<0)break;
        double low=0.0,high=l*0.5,mid;
        double l1,r;
        l1=l*(1.0+n*c);
        while(high-low>eps)//测试到1e-5才可以
        {
            mid=(high+low)/2.0;
            r=(4*mid*mid+l*l)/(8*mid);
            if(2*r*asin(l*0.5/r)<l1)low=mid;
            else high=mid;
        }
        printf("%.3f\n",mid);
    }

    return 0;
}






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值