HDU 2438 Turn the corner
来源:互联网 发布:百度数据研究中心 编辑:程序博客网 时间:2024/06/10 14:57
题目链接~~>
做题感悟:做完这题发现三分一定与数学知识相结合出现,而且不是简单的数学知识。
解题思路:关键是要找到小车的运动状态,下面是分析和公式推导。
在小车转弯过程中,黄线是不断地变化的,变化规律是先增大再减小(可以自己模拟一下,只要黄线最大值小于y,车就可以通过)。这样可以得到一个关于图中角度的公式,不断三分角度就可以得到最大的黄线长度了(采用三分是因为黄线所形成的函数是凸函数),角度(0 , PI / 2.0)。
代码:
#include<stdio.h>#include<iostream>#include<map>#include<stack>#include<string>#include<string.h>#include<stdlib.h>#include<math.h>#include<vector>#include<queue>#include<algorithm>using namespace std ;#define LEN sizeof(struct node)#define lld __int64const double PI = 3.1415926535898 ;const int INF = 99999999 ;const double esp = 1e-8 ;const int mod= 10000007 ;const int MX = 100005 ;double x,y,l,d ;double find(double k){ return l*sin(k)-x*tan(k)+d/cos(k) ;}double third_search(double le,double rt)// 三分{ double mid,midd ; while(rt-le>=esp) { mid=(rt+le)/2.0 ; midd=(rt+mid)/2.0 ; find(mid) > find(midd) ? rt = midd : le=mid ; } return find(le) ;}int main(){ while(~scanf("%lf%lf%lf%lf",&x,&y,&l,&d)) { if(third_search(0.0,PI/2.0)+esp<y) printf("yes\n") ; else printf("no\n") ; } return 0 ;}
转自~~>
0 0
- HDU 2438 Turn the corner
- hdu 2438 Turn the corner
- HDU 2438 Turn the corner
- HDU 2438 Turn the corner
- HDU 2438 Turn the corner
- Turn the corner HDU-2438
- 【HDU 2438】 Turn the corner
- HDU 2438 Turn the corner
- HDU Turn the corner
- Turn the corner HDU
- hdu 2438 - Turn the corner(三分)
- hdu 2438Turn the corner(三分)
- HDU 2438 Turn the corner(三分)
- HDU 2438 Turn the corner 三分法
- hdu 2438 Turn the corner(三分)
- HDU 2438 Turn the corner(三分)
- hdu-2438-Turn the corner(三分)
- HDU 2438 Turn the corner 三分
- 没事的时候一个人静静的想着往事
- Class文件格式实战:使用ASM动态生成class文件
- Android开发之ActionBar结合Fragment的导航功能的使用(源代码分享)
- java中利用反射机制得到一个类的所有构造方法,成员方法机器参数的列表
- 小述移动通信
- HDU 2438 Turn the corner
- 深入理解SQL的四种连接-左外连接、右外连接、内连接、全连接
- syntax error near unexpected token `elif'
- "扫雷外挂" 原理篇
- GSM?
- WAP、GPRS?
- POJ 1091 跳蚤 数论-容斥原理、扩展欧几里得
- 国内千万级手机端视频互动娱乐直播完整源码
- OOM