hrbeu1280Turn the corner
来源:互联网 发布:思路网源码 编辑:程序博客网 时间:2024/06/09 03:01
Turn the corner
TimeLimit: 1 Second MemoryLimit: 32 Megabyte
Totalsubmit: 661 Accepted: 184
Description
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
Every line has four real numbers, x, y, l and w.
Proceed to the end of file.
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
double Cal(double L){double s = l * cos(L) + w * sin(L) - x;double h = s * tan(L) + w * cos(L);return h;}
#include <iostream>#include <cstdio>#include <cmath>using namespace std;#define PI 3.1415926535897932384626const double EPS = 1e-10;double x,y,l,w;double Cal(double L){double s = l * cos(L) + w * sin(L) - x;double h = s * tan(L) + w * cos(L);return h;}double Solve(void){double Left, Right;double mid, midmid;double mid_value, midmid_value;Left = 0; Right = PI*0.5;while (Left + EPS < Right){mid = (Left + Right) / 2;midmid = (mid + Right) / 2;mid_value = Cal(mid);midmid_value = Cal(midmid);if (mid_value >= midmid_value) Right = midmid;else Left = mid;}return Cal(Left);}int main(){freopen("in.txt","r",stdin);while(cin>>x>>y>>l>>w){if(x<w||y<w) cout<<"no"<<endl;else{double H = Solve();if(H>0&&H<y) cout<<"yes"<<endl;else cout<<"no"<<endl;}}return 0;}
- hrbeu1280Turn the corner
- The Corner
- Turn the corner
- Turn the corner
- HDU Turn the corner
- Turn the corner+三分法
- hdu2438Turn the corner 三分
- HDU2438 Turn the corner
- hdoj2438Turn the corner【三分法】
- Turn the corner
- hdu2438 Turn the corner
- 5Turn the corner
- Turn the corner
- 1005 Turn the corner
- 1005 Turn the corner
- Turn the corner
- 1005 Turn the corner
- Turn the corner
- 系统重装--硬盘扩容--记录
- racle job详解
- 爱喝酒的程序员如何学习数据结构
- [转]浅谈Android五大布局(二)——RelativeLayout和TableLayout
- 如何制作串口线!!!
- hrbeu1280Turn the corner
- 使用catalog进行地图发布
- IIS6配置GZIP压缩网页来提升网页浏览速度
- UIApplication详解
- smarty 模版参数中的变量使用及变量的运算
- Sencha Cmd 3.0 使用入门
- 我对STM32F10x NVIC中断优先级的理解
- 我的JMyETL项目终于即将获得赞助了
- 使用vim+ctags+cscope阅读内核源码