acm 2 1005 Turn the corner

1.1005

2.

Turn the corner:

Mr. West bought a new car! So he is travelling around the city.
  One day he comes to a vertical corner. The street he is currently in has a width x, the street he wants to turn to has a width y. The car has a length l and a width d.
  Can Mr. West go across the corner?

Input

  four real numbers, x, y, l and w.
  
Output

  If he can go across the corner, print "yes". Print "no" otherwise.

Sample Input

10 6 13.5 4
10 6 14.5 4

Sample Output

yes
no

3.西先生买了一辆新车在城市旅行。
一天,他来到一个垂直的角落。他目前在街上有一个宽度×,他要转的街有一个宽度。这辆车有一个长度和宽度。
西先生能走到拐角吗?

4.

以车长为玄长,画四分之一圆,以此圆心为圆心,此圆半径减去车宽为半径再画四分之一圆。如果路拐角小圆之内,为yes,否则为no,如图:

5.

#include<iostream>
#include<string.h>
#include<set>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
double PI=acos(-1.0);
double s,h,l,w,x,y;
double car(double a)
{
    s=l*cos(a)+w*sin(a)-x;
    h=s*tan(a)+w*cos(a);
    return h;
}
int main()
{
        double right,left,m,mm;
    while(cin>>x>>y>>l>>w)
    {
        left=0;
        right=PI/2;
        while(right-left>0.0000001)
        {
            m=(right+left)/2;
            mm=(right+m)/2;
            if(car(m)>=car(mm)) right=mm;
            else left=m;
        }
        if(car(m)<=y) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值