第一次接触三分!

Turn the corner

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 34   Accepted Submission(s) : 17
Problem Description
Mr. West bought a new car! So he is travelling around the city.<br><br>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.<br><br>Can Mr. West go across the corner?<br><img src=../../../data/images/2438-1.jpg><br>
 

Input
Every line has four real numbers, x, y, l and w.<br>Proceed to the end of file.<br>
 

Output
If he can go across the corner, print "yes". Print "no" otherwise.<br>
 

Sample Input
  
  
10 6 13.5 4<br>10 6 14.5 4<br>
 

Sample Output
  
  
yes<br>no<br>
 

Source
2008 Asia Harbin Regional Contest Online
以后 
保证
做一个题
写一个博客!
不然 又忘了题意
#include<set>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<math.h>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
using namespace std;
double pi=acos(-1.0);
 double x,y,l,w;
 double pao(double g)
 {
     return l*cos(g)+(w-x*cos(g))/sin(g);
 }
 double paopao(double x1, double x2)
 {
     double t1,t2;
     double x3,x4;
     while(1)
     {
     x3=((2*x1)+x2)/3;
     x4=(x1+(2*x2))/3;
     t1=pao(x3);
     t2=pao(x4);
     if(t1<t2)
     {
         x1=x3;
     }
     else
     {
         x2=x4;
     }
     if(fabs(x2-x1)<1e-4)
     {
         return x2;
         break;
     }
     }
 }



int main()
{

    double pao1,pao2;
    while(cin>>x>>y>>l>>w)
    {

        pao1=0;
        pao2=pi/2;
        double hehe;
         hehe=paopao(pao1,pao2);
         if(pao(hehe)<=y)
         {
             cout<<"yes"<<endl;
         }
         else
         {
             cout<<"no"<<endl;
         }
    }
    return 0;
}

有得找

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值