【三分法】hdu2438 Turn the corner
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?
Proceed to the end of file.
10 6 14.5 4
#include<cstdio>
#include<cmath>
#include<iostream>
#define PI 3.14159
using namespace std; double x,y,l,d; double pd(double a)
{
return sin(a)*l+d/cos(a)-y*tan(a);
} int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
{
double lm,rm,le=0.0,r=PI/;
while(fabs(r-le)>1e-)
{
lm=(le*2.0+r)/3.0;
rm=(le+r*2.0)/3.0;
if(pd(lm)>pd(rm)) r=rm;
else le=lm;
}
if(pd(le)<=y)
printf("yes\n");
else
printf("no\n");
}
}
【三分法】hdu2438 Turn the corner的更多相关文章
- HDU2438 Turn the corner【三分法】【数学几何】
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU2438:Turn the corner(三分)
传送门 分析 根据这张图,我们只要使得h<=y即可,可以发现h是一个凸函数,故使用三分,具体见代码 代码 #include<cstdio> #include<cstring&g ...
- Turn the corner (三分)
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- hdu 2348 Turn the corner(三分&&几何)(中等)
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 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 ...
- HDU 2438 Turn the corner(三分查找)
托一个学弟的福,学了一下他的最简便三分写法,然后找了一道三分的题验证了下,AC了一题,写法确实方便,还是我太弱了,漫漫AC路!各路大神,以后你们有啥好的简便写法可以在博客下方留个言或私信我,谢谢了! ...
- hdu 2438 Turn the corner [ 三分 ]
传送门 Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdu 2438 Turn the corner(几何+三分)
Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...
随机推荐
- hdu 1233 还是畅通project(kruskal求最小生成树)
还是畅通project Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- Linux 高速操作IOport
在嵌入式设备中对GPIO的操作是最主要的操作. 一般的做法是写一个单独驱动程序,网上大多数的样例都是这种.事实上linux以下有一个通用的GPIO操作接口.那就是我要介绍的 "/sys/cl ...
- 关于signal和fork的思考
fork可以在linux中创建子进程.先看man手册里面的东西: SYNOPSIS #include <unistd.h> pid_t fork(void);DES ...
- 四、Spring Boot 多数据源 自动切换
实现案例场景: 某系统除了需要从自己的主要数据库上读取和管理数据外,还有一部分业务涉及到其他多个数据库,要求可以在任何方法上可以灵活指定具体要操作的数据库.为了在开发中以最简单的方法使用,本文基于注解 ...
- Android查缺补漏(View篇)--在 Activity 的 onCreate() 方法中为什么获取 View 的宽和高为0?
在 Activity 的 onCreate() 方法中为什么获取 View 的宽和高为0 ? @Override protected void onCreate(Bundle savedInstanc ...
- 用Azure AD 实现Web 应用身份认证的Multi-Factor Authentication(MFA)
最近客户有个需求,希望把面向public的Web应用中的终端用户数据库由Azure AD来实现,同时希望可以用MFA来实现用户身份认证.这个想法非常好,通过使用Azure的managed servic ...
- CentOS ifconfig无IP地址解决办法
修改/etc/sysconfig/network-scripts/ifcfg-ens33 把 ONBOOT 改为 yes,重启后就会有ip,且物理机和虚拟机可以互相ping通了.
- 【CSS3】透明度opacity与rgba()区别、光标cursor、display、轮廓outline与margin及border区别、em和rem区别
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 统计nginx单个IP访问日志并获取IP来源
#!/usr/bin/env python #coding=utf-8 import requests from urllib2 import urlopen # import lxml.html f ...
- 搭建和测试 Redis 主备和集群
本文章只是自我学习用,不适宜转载. 1. Redis主备集群 1.1 搭建步骤 机器:海航云虚机(2核4GB内存),使用 Centos 7.2 64bit 操作系统,IP 分别是 192.168.10 ...