UVa --10566

题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1507


设 交点到右端点的距离为 d 底边长为 L 

则有三角形相似得     d / L = c / sqrt(y^2 - L^2)               (1)

       (L - d) / L= c / sqrt(x^2 - L ^2);      (2)

由(1)(2)可得   1 - c / sqrt(y^2 - L^2)  - c / sqrt(x^2 - L ^2) = 0;

有上式可得 L越大 左式越小,即为减函数  二分求L

#include<stdio.h>
#include<math.h>
#define min(a,b) (a<b?a:b)
double x,y,c;
double f(double L)
{
    return 1 - c / sqrt(y*y - L*L) - c / sqrt(x*x - L*L) ;
}
void search(double y1)
{
    double x1 = 1;
    double mid ;
    while(y1 - x1 > 0.00001)
    {
        mid = (x1 + y1) / 2.0 ;
        if(f(mid) < 0) y1 = mid;
        else x1 = mid ;
    }
    printf("%.3lf\n",mid);

}
int main()
{
    while(scanf("%lf%lf%lf",&x,&y,&c)!=EOF)
    {
        int _min;
        _min = min(x,y);
        search(_min);
    }
}



 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值