zoj 3023 Light Bulb
题目大意:

求L的最大值
思路:
可以想象出是一个关于人到灯泡距离x的单峰上凸函数
当光线在墙角左边的时候影子在不断增长
然后通过相似可以推出人在墙上影子的长度为:H+D*(h-H)/x
再加上地上的D-x就可以计算出每个x的函数值了
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define inf 2139062143
#define ll long long
#define MAXN 1001000
#define eps 1e-4
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') f=-;ch=getchar();}
while(isdigit(ch)) {x=x*+ch-'';ch=getchar();}
return x*f;
}
double H,h,d;
double calc(double x){return H+(h*d-H*d)/x+d-x;}
int main()
{
int T=read();
while(T--)
{
scanf("%lf%lf%lf",&H,&h,&d);
double r=d,l=d-h*d/H,ml,mr;
while(r-l>eps)
{
ml=(r-l)/3.0+l,mr=*(r-l)/3.0+l;
if(calc(ml)>calc(mr)) r=mr;
else l=ml;
}
printf("%.3lf\n",calc(r));
}
}
zoj 3023 Light Bulb的更多相关文章
- ZOJ 3203 Light Bulb (三分+计算几何)
B - Light Bulb Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit ...
- 三分 --- ZOJ 3203 Light Bulb
Light Bulb Problem's Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: ...
- ZOJ 3203 Light Bulb - 求导求最大值
如果L全在地面上: 输出 h * D / H 如果L全在墙上: 输出 h 否则: (D - X ) / X = Y / (H - h) L = D - X + h - Y 然后对L求导即可 #incl ...
- zoj 3203 Light Bulb,三分之二的基本问题
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
- ZOJ 3203 Light Bulb (三分查找)
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
- ZOJ 3203 Light Bulb
Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow a ...
- ZOJ 3203 Light Bulb(数学对勾函数)
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
- [清华集训2015]灯泡(浙江大学ZOJ 3203 Light Bulb)
Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, his brother ...
- ZOJ 3203 Light Bulb( 三分求极值 )
链接:传送门 题意: 求影子长度 L 的最大值 思路:如果 x = 0 ,即影子到达右下角时,如果人继续向后走,那么影子一定是缩短的,所以不考虑这种情况.根据图中的辅助线外加相似三角形定理可以得到 L ...
随机推荐
- Python 软件开发目录规范
目录规范: ATM #工程文件夹 ------| bin #用来存放可执行文件的 |---- start.py conf #用来存放配置信息的 |---- settings.py lib ...
- nginx虚拟主机配置实践
1.配置基于域名的虚拟主机 [root@web01 html]# egrep -v "#|^$" /application/nginx/conf/nginx.conf.defaul ...
- 56.fielddata filter的细粒度内存加载控制
语法: POST /test_index/_mapping/test_type { "properties": { "test_field": { " ...
- python爬虫学习,使用requests库来实现模拟登录4399小游戏网站。
1.首先分析请求,打开4399网站. 右键检查元素或者F12打开开发者工具.然后找到network选项, 这里最好勾选perserve log 选项,用来保存请求日志.这时我们来先用我们的账号密码登陆 ...
- 选项B中:int b[][3]={0,1,2,3}
选项B中:int b[][3]={0,1,2,3};等价于 int b[][3]={0,1,2,3,0,0}; int b[][3]={0,1,2,3,4}; cout<& ...
- 74-A/D指标,Accumulation/Distribution,积累/派发线,离散指标.(2015.7.1)
A/D指标,Accumulation/Distribution 积累/派发线,离散指标 观井映天 2015.7.1
- <git>……git的基本使用……//
1.切换到存放git版本库的地方 2.Git clone url(github上的地址) 3.设置全局用户(输入一次即可) git config --global user.name github上的 ...
- hdu 4770 状压+枚举
/* 长记性了,以后对大数组初始化要注意了!140ms 原来是对vis数组进行每次初始化,每次初始化要200*200的复杂度 一直超时,发现没必要这样,直接标记点就行了,只需要一个15的数组用来标记, ...
- vagrant的学习 之 ThinkPHP5.1
vagrant的学习 之 ThinkPHP5.1 本文根据慕课网的视频教程练习,感谢慕课网! 慕课视频学习地址:https://www.imooc.com/video/14218. 慕课的参考文档地址 ...
- hibernate详解一
hibernate介绍 hibernate是一个开源的轻量级的框架, hibernate框架应用在javaee三层结构中的dao层框架,在dao层对数据库进行crud操作,使用hibernate框架实 ...