第一次接触三分!

来源:互联网 发布:网店关键词优化 编辑:程序博客网 时间:2024/05/21 06:50

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;}

有得找

0 0
原创粉丝点击