传送门

Turn the corner

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2081    Accepted Submission(s): 787

Problem 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
 
Source
 
Recommend
gaojie   |   We have carefully selected several similar problems for you:  2444 2441 2442 2443 2440
 
 
题解转一发:
http://www.cnblogs.com/wally/archive/2013/05/14/3077383.html
 

网上大牛思路:

可以根据边界,汽车已经转弯,设水平方向为x轴,垂直方向为y轴。

则汽车的内边界(靠近里面的边界)的直线方程式f(x)为:y=x*tan(a)+l*sin(a)+d/cos(a).其中a是汽车与x轴的夹角

当y=X时,求解出的-x即为汽车的内边界到y轴的距离h,若h小于Y即可转弯,若大于Y就不能转弯。
所以只需要利用方程式,求-x的最大值,即可判断能否通过。
由于f(x)是凸函数(随着x的增大y先增大后减小),所以,需要借助三分求解。

图示:

第一道三分求极值题啊!!!

Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
13216500 2015-03-23 09:01:02 Accepted 2438 0MS 1688K 946 B G++ czy
 #include <cstdio>
#include <cmath> using namespace std; const double mi = 1e-;
const double eps = 1e-;
const double pi = 4.0 * atan(1.0); double x,y,l,d; double cal(double a)
{
return (-x + l * sin(a) + d / cos(a)) / tan(a) ;
} int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
{
if(d>y || d>x){
printf("no\n");continue;
}
double low=,high = pi / ,mid,mmid;
double te1,te2;
while(high - low > mi)
{
mid = (low + high) / ;
mmid = (low + mid) / ;
te1 = cal(mid);
te2 = cal(mmid);
if(te1 > te2){
low = mmid;
}
else{
high = mid;
}
}
te1 = cal(low);
if(te1 < y){
printf("yes\n");
}
else{
printf("no\n");
}
}
}

最新文章

  1. 给 Android 研发的一些的建议
  2. textarea 中的 innerHTML 和 value
  3. Ubantu 下安装 tensorflow
  4. CAS代理配置
  5. 可能是Mac环境变量恢复的参考
  6. mono+jexus 之连接数据库
  7. Clairewd’s message
  8. Linux SSH常用总结(转)
  9. Myeclipse 10 for mac 破解版下载安装及破解方法
  10. win10+ubuntu17.04双系统安装与卸载(uefi+gpt)及常见软件安装
  11. Oracle ADG搭建
  12. redis慢日志
  13. flex与js通信、在浏览器中打开新窗口
  14. 限制oracle某用户仅能从某IP登录
  15. nnet3 TDNN chunk, left-context, right-context
  16. WSL优化 (Windows Subsystem for Linux) Linux子系统优化配置
  17. python之路--触发器, 储存过程, 事务
  18. Django中使用Celery
  19. [蓝桥杯]ALGO-124.算法训练_数字三角形
  20. css3实现切片动画

热门文章

  1. obj.style 和currentstyle 等区别
  2. std::map插入已存在的key时,key对应的内容不会被更新
  3. 善用Object.defineProperty巧妙找到修改某个变量的准确代码位置
  4. 用Vue的方式实现复选框
  5. django 模板中{%for%}的使用
  6. vue 数据没有驱动视图?
  7. java_日期和时间
  8. xshell通过xftp传输Windows文件到Linux:在输入put后,再摁 TAB 键,可显示当前文件夹的文件
  9. ios 之sqllite
  10. Visual C++中error spawning cl.exe错误的两种解决方法.