zoukankan      html  css  js  c++  java
  • POJ 1905 Expanding Rods (求直杆弯曲拱起的高度)(二分法,相交弦定理)

    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

                                 

            

    若圆内任意弦AB、弦CD交于点P,则PA·PB=PC·PD(相交弦定理)

    sinB=L/R   B=asin(L/R)   反三角函数。

     1 #include<cstdio>
     2 #include<cmath>
     3 int main()
     4 {
     5     int t;
     6     scanf("%d",&t);
     7     int num=0;
     8     while(t--)
     9     {
    10         double l,n,c,L,le,ri,r,mid;
    11         scanf("%lf %lf %lf",&l,&n,&c);
    12         L=(1+n*c)*l;
    13         le=0;
    14         ri=l/2;
    15         while(ri-le>1e-6)
    16         {
    17             mid=(le+ri)/2;
    18             r=l*l/8/mid+mid/2;
    19             if(r*2*(asin(l/2/r))<L)
    20             {
    21                 le=mid;
    22             }
    23             else
    24             {
    25                 ri=mid;
    26             }
    27         }
    28         printf("Case %d: ",++num);
    29         printf("%.6f
    ",le);
    30     }
    31 }
    ——将来的你会感谢现在努力的自己。
  • 相关阅读:
    判断DataSet为空
    msxml3.dll 错误 '800c0008'
    google Map api地理位置坐标转换
    C# .net中cookie值为中文时的乱码解决方法
    windows pear 安装
    smarty2 设置、变量、函数
    简单模板类
    mysql 1366 插入错误
    Oracle修改账户口令
    C# Winform验证码
  • 原文地址:https://www.cnblogs.com/yexiaozi/p/5708990.html
Copyright © 2011-2022 走看看