HDU 2438 Turn the corner(三分查找)
托一个学弟的福,学了一下他的最简便三分写法,然后找了一道三分的题验证了下,AC了一题,写法确实方便,还是我太弱了,漫漫AC路!各路大神,以后你们有啥好的简便写法可以在博客下方留个言或私信我,谢谢了!
Turn the corner
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3196 Accepted Submission(s): 1302
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?
#include <bits/stdc++.h>
using namespace std;
double x,y,l,w;
const double eps=1e-;
const double pi=acos(-1.0);
double solve(double angle)
{
return (-x+l*sin(angle)+w/cos(angle))/tan(angle);
}
int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&w)!=EOF)
{
double ll=,rr=pi/,midx,midy;
while(rr-ll>eps)
{
midx=(ll+ll+rr)/;
midy=(ll+rr+rr)/;
if(solve(midx)>solve(midy))
rr=midy;
else ll=midx;
}
if(solve(ll)<y)
printf("yes\n");
else printf("no\n");
}
return ;
}
HDU 2438 Turn the corner(三分查找)的更多相关文章
- hdu 2438 Turn the corner [ 三分 ]
传送门 Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdu 2348 Turn the corner(三分&&几何)(中等)
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 2438 Turn the corner(几何+三分)
Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...
- Turn the corner (三分)
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)
B. The Meeting Place Cannot Be Change ...
- HDU 5144 NPY and shot(物理运动学+三分查找)
NPY and shot Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- hdu 2438Turn the corner 三分
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- hdu 2438
Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...
- Turn the corner
Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...
随机推荐
- 【bird-front】前端框架介绍
bird前端项目,基于react.antd.antd-admin,封装常用数据组件,细粒度权限解决方案. bird-front是基于react的后台管理系统前端项目,框架构建部分严重借鉴于antd管理 ...
- APP Store开发指南
App Store 审核指南 iOS App打包上架超详细流程 ---2017.03 苹果对开发者提交的应用的审核之严格是出了名的,了解苹果的审核标准对于开发者防止应用被拒有着十分重要的意义.几天前苹 ...
- php多语言切换---转载
文件内容: /include/language.php <?php $languages = array (); $languages ['zh-cn'] ["name"] ...
- vue2.0路由变化1
路由的步骤 1.定义组件 var Home={ template:'<h3>我是主页</h3>' }; var News={ template:'<h3>我是新闻& ...
- SpringMVC处理multipart请求.
一.简述 multipart格式的数据会将一个表单拆分为多个部分(part),每个部分对应一个输入域.在一般的表单输入域中,它所对应的部分中会放置文本型数据,但是如果上传文件的话,它所对应的部分可以是 ...
- centos 7 部署 open-falcon 0.2.0
=============================================== 2017/12/06_第2次修改 ccb_warlock 更 ...
- unity创建和加载AssetBundle
先说一下为什么要使用AssetBundle吧,以前做东西一直忽略这个问题,现在认为这个步骤很重要,代码是次要的,决策和为什么这样搞才是关键. 一句话概括吧,AssetBundle实现了资源与服务分离, ...
- VS2010安装OpenGL
以下涉及到的所有资源都在这里: 链接:https://pan.baidu.com/s/1eSctT5K 密码:174s *我的VS2010的安装位置:D:\Program Files (x86)\M ...
- MySQL一对一:一对多:多对多: 实例!!!!
学生表和课程表可以多对多 一个学生可以学多门课程 一门课程可以有多个学生: 多对多 *** 一个学生对应一个班级 一个班级对应多个学生: 一对多 *** 一个老师对应多个学生 多个学生对应一个老师:一 ...
- php isset和empty方法的区别
我总结了下面几点区别,直接上代码: empty方法: 变量不存在,返回true 变量存在,值为空,返回true 变量存在,值不为空,返回false function empty1(){ //变量不存在 ...