• 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 }
    ——将来的你会感谢现在努力的自己。
  • 相关阅读:
    Oracle数据库导入(数据泵导)
    C# 根据WCF 的url动态调用WCF
    winform嵌套浏览器
    微信支付服务商模式 配置
    结对项目-增强型科学计算器
    vscode编辑远程linux系统下c/c++代码实现代码补全
    Linux development with C++ in Visual Studio
    用VS2015开发Linux程序详细教程-配置篇
    Go语言环境搭建详解(2020版)
    bat脚本实现后台运行cmd命令
  • 原文地址:https://www.cnblogs.com/yexiaozi/p/5708990.html
Copyright © 2020-2023  润新知