HDU 2438 Turn the corner

题解在此:点击打开链接

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

#define eps 1e-5
const double pi=acos(-1.0);

double x,y,l,w;

double Cal(double k)
{
    return l*cos(k)+(w-x*cos(k))/sin(k);
}

double T_Find()
{
    double l=0,r=pi/2,ll,rr;
    while(r-l>eps)
    {
        ll=l+(r-l)/3;
        rr=r-(r-l)/2;
        double Ans1=Cal(ll),Ans2=Cal(rr);
        if(Ans1<Ans2)
            l=ll;
        else r=rr;
    }
    return Cal(l);
}

int main()
{
    while(scanf("%lf%lf%lf%lf",&x,&y,&l,&w)!=EOF)
    {
        double pd=T_Find();
        if(pd<=y)
            printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值