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 ...
随机推荐
- Sql语句的一些事(二)
与sql语句的书写顺序并不是一样的,而是按照下面的顺序来执行 from--where--group by--having--select--order by, from:需要从哪个数据表检索数据 wh ...
- 合办大学 -- internal campus in China
* 合办大学 -- internal campus in China- international campus zhejiang University- 南方科技大学 - 西交利物浦大学(Xi’an ...
- ICE CAVE(BFS搜索(模拟))
Description You play a computer game. Your character stands on some level of a multilevel ice cave. ...
- UVA 213 信息解码(二进制&位运算)
题意: 出自刘汝佳算法竞赛入门经典第四章. 考虑下面的01串序列: 0, 00, 01, 10, 000, 001, 010, 011, 100, 101, 110, 0000, 0001, …, 1 ...
- 九度oj 题目1182:统计单词
题目1182:统计单词 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4780 解决:1764 题目描述: 编一个程序,读入用户输入的,以“.”结尾的一行文字,统计一共有多少个单词,并分别 ...
- uva10537 最短路 倒推
题意:知道了,最后需要的,那么就倒着最短路,推出去就可以了. 以最短路的方式来解决.
- Python模块:logging、
logging模块: 很多程序都有记录日志的需求,并且日志中包含的信息既有正常的程序访问日志,还可能有错误.警告等信息输出.Python的logging模块提供了标准的日志接口,你可以通过它存储各种格 ...
- 主席树初探--BZOJ1901: Zju2112 Dynamic Rankings
n<=10000的序列做m<=10000个操作:单点修改,查区间第k小. 所谓的主席树也就是一个值域线段树嘛..不过在这里还是%%fotile 需要做一个区间查询,由于查第k小,需要一些能 ...
- Our Journey of Dalian Ends 乌鲁木齐网络赛 最小费用最大流
Life is a journey, and the road we travel has twists and turns, which sometimes lead us to unexpecte ...
- hdu4701 Game(递推博弈)
题意: Alice初始有A元,Bob有B元. 有N个物品,第i个物品价值为Ci.Alice和Bob轮流买一些(>=1)物品.不能移动的人输.购买有一个限制,对于第1 个之后物品,只有当第i-1个 ...