ZOJ 3203 灯泡】的更多相关文章

题面 相比 wildleopard 的家,他的弟弟 mildleopard 比较穷.他的房子是狭窄的而且在他的房间里面仅有一个灯泡.每天晚上,他徘徊在自己狭小的房子里,思考如何赚更多的钱.有一天,他发现他的影子的长度随着他在灯泡和墙壁之间走到时发生着变化.一个突然的想法出现在脑海里,他想知道他的影子的最大长度.  思路 首先,分治肯定是能够想到的,但是是二分还是三分呢,我们只需要思考一下就能知道,我们设地上影长为L1,墙上为L2,人走近时L1增加,L2减小,走远时L1减小,L2增加——这是个二次…
B - Light Bulb Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3203 Description Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only o…
Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only one light bulb in his house. Every night, he is wandering in his incommodious house, t…
Light Bulb Problem's Link:   http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: 灯的位置固定,而人的位置不固定,求人的影子的最大长度. analyse: 当灯.人的头部.右墙角在同一条直线上时,此时人的影子全部在地板上:当人继续往右走的时候,影子分为地板上的和墙上的,由此可见这是一个先增后减的凸函数,三分取最大值即可. double cal(Type a) { return…
三分: 和二分非常类似的一个算法,与二分不同的是 二分是单调的,而三分是一个先增后减或者先减后增 三分可以求出峰值. 注意三分一定是严格单调的,不能有相等的情况. 讲个例题: 题目 题意: 一个人发现他的影子的长度随着他在灯泡和墙壁之间走到时发生着变化.一个突然的想法出现在脑海里,他想知道他的影子的最大长度. 例图: 输入格式 输入文件的第一行包含一个整数 ,表示测试数据的组数. 对于每组测试数据,仅一行,包含三个实数 , 和 , 表示灯泡的高度, 表示 mildleopard 的身高, 表示灯…
如果L全在地面上: 输出 h * D / H 如果L全在墙上: 输出 h 否则: (D - X ) / X = Y / (H - h) L = D - X + h - Y 然后对L求导即可 #include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> using namespace std; int main(){ double H,h,D,x,y,x0; int…
Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only one light bulb in his house. Every night, he is wandering in his incommodio…
Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only one light bulb in his house. Every night, he is wandering in his incommodio…
Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only one light bulb in his house. Every night, he is wandering in his incommodious house, thinking of how to earn more money. One day, he fo…
Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only one light bulb in his house. Every night, he is wandering in his incommodio…