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 ...
随机推荐
- DotNetCore跨平台~功能测试TestHost的使用
回到目录 之前写了关于自动化测试的相关文章,包括gitlab,unittest,jenkins pipeline等,基于都是功能点的测试,当我们的框架或者业务修改之后,需要走一篇自动化测试,以此来保证 ...
- iOS学习之Socket使用简明教程- AsyncSocket
转载自:http://my.oschina.net/joanfen/blog/287238 如果需要在项目中像QQ微信一样做到即时通讯,必须使用socket通讯,本人也是刚学习,分享一下,有什么不对的 ...
- htpasswd 命令详解
htpasswd参数 -c 创建passwdfile.如果passwdfile 已经存在,那么它会重新写入并删去原有内容. -n 不更新passwordfile,直接显示密码 -m 使用MD5加密(默 ...
- JPA实体类注解、springboot测试类、lombok的使用
前提准备: 搭建一个springboot项目,详情请参见其它博客:点击前往 1 引入相关依赖 web.mysql.jpa.lombok <?xml version="1.0" ...
- php运行C++程序
linux命令:gcc hello.cpp -lstdc++ -o hello.o php代码: <?php $command="./hello.o "; passthru( ...
- Linux目录结构详解
/: 根目录,一般根目录下只存放目录,不要存放文件,/etc./bin./dev./lib./sbin应该和根目录放置在一个分区中/bin:/usr/bin: 可执行二进制文件的目录,如常用的命令ls ...
- 浅谈OGNL表达式
OGNL(Object-Graph Navigation Language):对象视图导航语言 ${user.addr.name}这样的写法就叫对象视图导航 OGNL不仅可以视图导航,支持EL表达式更 ...
- Webpack 2 视频教程 016 - Webpack 2 中生成 SourceMaps
原文发表于我的技术博客 这是我免费发布的高质量超清「Webpack 2 视频教程」. Webpack 作为目前前端开发必备的框架,Webpack 发布了 2.0 版本,此视频就是基于 2.0 的版本讲 ...
- JavaScript的DOM编程--05--获取文本节点
获取文本节点: 1). 步骤: 元素节点 --> 获取元素节点的子节点 2). 若元素节点只有文本节点一个子节点, 例如 <li id="bj" name=" ...
- Node.js 蚕食计划(一)—— 模块化编程
众所周知,Node.js 的出现造就了全栈工程师,因为它让 JavaScript 的舞台从浏览器扩大到了服务端 而 Node.js 的强大也得益于它庞大的模块库,所以学习 Node.js 第一步还得从 ...