UVALive - 7198 Tall orders (构造函数等式二分求参数)

本文介绍了一种评估电力电缆是否安全地跨越铁路的方法。通过测量关键数据,如支柱高度和间距,利用数学公式确定电缆的最大安全长度,确保新型Macho10000列车能安全通过。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

You have been charged with evaluating the safety of power cables passing over train tracks. Owing to the recent purchase of the new Macho 10000 trains, the questions has been raised as to whether the trains are too tall to safely pass under existing power cable infrastructure. The new Macho 10000 train is 4.1 m tall; the power engineers claim that the power lines have been designed for a maximum train height of 4.05 m, with a safety gap of 150 mm for thermal expansion in the cables. Fortunately the data required to test this claim is available: you have a complete database of the critical dimensions of all power line infrastructure passing over train tracks. In particular, you have the following dimensions (see Figure 1): • The distance between the two posts supporting the power cable, d. You may safely assume that the train track is exactly halfway between the two posts. • The height of the top of the posts above the track, p. You may safely assume that the cable is attached right at the top of the post. Figure 1: Power line dimensions A cable hanging between poles is known to assume a specific shape called a catenary. This shape is described by the formula f(s) = a cosh ( s a ) where −d 2 ≤ s ≤ d 2 denotes a position along the cable, as measured on the ground, and cosh(x) = e x + e −x 2 A given configuration (specific d and p values) can be said to be safe if the lowest point along the cable is at a height of 4.2 m above the track. By modeling the cable as an infinitely thin thread, the function f(s) can be used to determine the maximum length of cable that will be safe. Input Your input consists of an arbitrary number of records, but no more than 100. Each record comprises two real numbers, p d where 4.3 ≤ p ≤ 10 denotes the height of the top of the posts above the tracks (in metres), and 6 ≤ d ≤ 30 denotes the distance between the two posts, also given in metres (see Figure 1). The end of input is indicated by a line containing only the value ‘-1’. Output For each input record, output L where L denotes the maximum length of cable that may be used while keeping the lowest point along the cable 4.2 m or more above the tracks. The value L should be given in metres, and should be truncated (not rounded) to three places after the decimal point. Sample Input 6 12 6.210381 10.184095 -1 Sample Output 12.692 11.175

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
double Find_a(double p,double d)  //这个是单调减函数,和单调增函数有所区别
{
    double low=0;
    double high=1e10;
    double mid;
    while(low+1e-7<high)
    {
        mid=(low+high)/2;                            //构造函数等式二分求参数
        if(mid*cosh(d/(2*mid))-mid*cosh(0)>=p-4.2)   //利用函数差值求a,
        low=mid;                                     //a可以取到很大,只要满足这个函数关系就行
        else
        high=mid;
    }
    return high;
}
int main()
{
    double p,d;
    double a;
    while(1)
    {
        scanf("%lf",&p);
        if(p==-1)
        break;
        scanf("%lf",&d);
        a=Find_a(p,d);
        printf("%f",a);
        double len=2*a*sinh(d/(2*a));            //由曲线积分得来
        len = (int)(len * 1000) / 1000.0;        //not rounded,不四舍五入的意思
        printf("%.3f\n",len);
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值