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<algorit…
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…
Light Bulb Problem's Link:   http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: 灯的位置固定,而人的位置不固定,求人的影子的最大长度. analyse: 当灯.人的头部.右墙角在同一条直线上时,此时人的影子全部在地板上:当人继续往右走的时候,影子分为地板上的和墙上的,由此可见这是一个先增后减的凸函数,三分取最大值即可. double cal(Type a) { return…
如果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…
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…
链接:传送门 题意: 求影子长度 L 的最大值 思路:如果 x = 0 ,即影子到达右下角时,如果人继续向后走,那么影子一定是缩短的,所以不考虑这种情况.根据图中的辅助线外加相似三角形定理可以得到 L = D * (h-x)/(H-x) + x , 再经过一些变形后可知这个 L = D * ( H - h )/( x - H ) + ( x - H ) + H + D ,明显的对号函数在左侧的图像,所以一定是个 凸函数 ,用三分求出极值即可 /**************************…