TOJ 2814 Light Bulb】的更多相关文章

Description 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. On…
Light Bulb Problem's Link:   http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: 灯的位置固定,而人的位置不固定,求人的影子的最大长度. analyse: 当灯.人的头部.右墙角在同一条直线上时,此时人的影子全部在地板上:当人继续往右走的时候,影子分为地板上的和墙上的,由此可见这是一个先增后减的凸函数,三分取最大值即可. double cal(Type a) { return…
ZOJ Problem Set - 3203 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 wand…
如果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…
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 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…
A. Light Bulb Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 32768KB   64-bit integer IO format: %lld      Java class name: Main   Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has…
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…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 题意:求影子的最长长度L; 当灯,人头和墙角成一条直线时(假设此时人站在A点),此时的长度是影子全在地上的最长长度.当人再向右走时,影子开始投影到墙上,当人贴着墙,影子长度即为人的高度.所以当人从A点走到墙,函数是先递增再递减,为凸性函数,所以我们可以用三分法来求解. 我们假设:人距离灯的水平距离为x,则不难推出:随着x的变化,L = D - x + H - D *…
题意:人左右走动,求影子L的最长长度. 思路:三分人在D上的位置.注意影子长=D-x+H-(H-h)*D/x. #include<iostream> #include<stdio.h> #include<stdlib.h> #include<memory.h> #include<string.h> #include<algorithm> #include<cmath> #define clc(a,b) memset(a,b…
题目描述: 如图,你可以在房间里移动,灯泡的高度为H,你的身高为h,灯泡与墙的水平距离为D,求你影子的最长长度(影子长度=地上影子长度+墙上影子长度) 样例输入: 0.5 样例输出: 1.000 0.750 4.000 此题是一道三分模板题 用x表示墙上影子的长度,根据相似三角形可以得到地上的影子长度为(h-x)*d/(H-x) 如图: 三分答案求x即可 #include<iostream> #include<cstdio> #include<cstdlib> #inc…
题目大意: 求L的最大值 思路: 可以想象出是一个关于人到灯泡距离x的单峰上凸函数 当光线在墙角左边的时候影子在不断增长 然后通过相似可以推出人在墙上影子的长度为:H+D*(h-H)/x 再加上地上的D-x就可以计算出每个x的函数值了 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorit…
也就是loj上的#10016灯泡了... 先上原图: 因为长度肯定是个开口向下的二次函数,所以先是确定用三分来找位置,然后想办法求出当前阴影长度 看到这条斜线,就想到了一次函数,所以就建了一个系,没想到还真解出来了. 首先设灯泡位置为(H,0),再设它与人头之间连接的线段所在直线为y=kx+b 所以b=H(在灯泡处入x=0代可以解出来),k=(h-b)/x=(h-H)/x(这个不用解释吧) 所以这条直线(也就是光线)与地面相交于y=0时 即x1=-b/k. 因为b,k已知,所以肯定求得出来 然后…
链接:传送门 题意: 求影子长度 L 的最大值 思路:如果 x = 0 ,即影子到达右下角时,如果人继续向后走,那么影子一定是缩短的,所以不考虑这种情况.根据图中的辅助线外加相似三角形定理可以得到 L = D * (h-x)/(H-x) + x , 再经过一些变形后可知这个 L = D * ( H - h )/( x - H ) + ( x - H ) + H + D ,明显的对号函数在左侧的图像,所以一定是个 凸函数 ,用三分求出极值即可 /**************************…
题意:灯离地面的高度为$H$,人的身高为$h$,灯离墙的距离为$D$,人站在不同位置,影子的长度不一样,求出影子的最长长度. 思路:设人离灯的距离为$x$,当人走到距离灯长度为$L$时,人在墙上的影子消失,此时人再往前走,影子的长度必然会减小,此时的$L$就为三分的左边界,右边界为$R=D$,由形似三角形可以推导出$L=D-\frac{h*D}{H}$,影子的长度 $$f(x)=D-x+H-\frac{(H-h)*D}{x},x\in [D-\frac{h*D}{H},D]$$ 在区间$[D-\…
三分: 和二分非常类似的一个算法,与二分不同的是 二分是单调的,而三分是一个先增后减或者先减后增 三分可以求出峰值. 注意三分一定是严格单调的,不能有相等的情况. 讲个例题: 题目 题意: 一个人发现他的影子的长度随着他在灯泡和墙壁之间走到时发生着变化.一个突然的想法出现在脑海里,他想知道他的影子的最大长度. 例图: 输入格式 输入文件的第一行包含一个整数 ,表示测试数据的组数. 对于每组测试数据,仅一行,包含三个实数 , 和 , 表示灯泡的高度, 表示 mildleopard 的身高, 表示灯…
[Terrain Engine] 1.When you press F, wherever your mouse is positioned will be moved to the center of the Scene View. This allows you to touch up an area, and quickly zoom over to a different area and change something else. If your mouse is not hover…
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…
If you are experiencing problems with LED holiday lighting, the following guides will provide advice and solutions for common Christmas light issues. What should I do if the light is off? Check that all circuits are switched on and that all plugs hav…
In the long and interesting history of Christmas lights, nothing is brighter than light-emitting diodes (or LEDs). But what makes LED Christmas lights such a powerful light source? And how to create colors in the LEDs? LEDs not only make more efficie…
Wake up in a strange hotel room in the evening and find the way to the bathroom, without stepping on the toes or being blinded by the wall switch lights, this can be a daunting task. The use of travel nightlights not only provides light, but also pro…
1.如果你继续发烧,我就去请医生过来If your fever continues, I'll send for the doctor.2.在这么大的停车场里,我是永远都找不到我的车的I'll never find my car in this huge parking lot.3.这些图表表明我们明年又会是成功的一年These figures point to our having a very successful year next year.4.这个红色电话亭现在很少被用到The red…
JavaScript是世界上最流行的编程语言.这门语言可用于HTML和web,更可广泛用于服务器.PC.笔记本电脑和智能手机等设备.-----------------------------------------------------------JavaScript的特点如下: 1.它是属于网络的脚本语言.它是因特网上最流行的脚本语言.2.它被数百万计的网页用来改进设计.验证表单.检测浏览器.创建cookies,以及更多的应用.3.它是一种轻量级的编程语言:4.它是可插入HTML页面的编程代…
第一部分 1 初级句型-简单句(Simple Sentences):(1.1)基本句型&补语.(1.2)名词短语&冠词.(1.3)动词时态.(1.4)不定式短语.(1.5)动名词.(1.6)分词.(1.7)形容词.(1.8)副词.(1.9)语气词.(1.10)介词.(1.11)主谓一致性   1.1 五种基本句型&补语 1.1.1 五中基本句型 主谓(sv) 主谓宾(svo) 主谓宾宾(svoo) 主谓补(svc) 主谓宾补(svoc) 一个句子需要“主语”+“动词(谓语)”才能表…
实验二 PHP基本语法实验 0 实验准备 0.1实验环境和相关工具软件 具体到的机房环境,请在Windowsxp环境下做本实验: l  操作系统:Windowsxp l  Web服务器:Apache 2.0.63  默认发布文档路径:c:\Apache\htdocs l  PHP:PHP5.2.11  安装路径:c:\php l  数据库:MySQL 5.1.39  使用默认路径 l  脚本编辑器: 记事本 或 EditPlus-v3.11.463H 或 Macromedia Dreamweav…
一个造物游戏: acidrain=rain+smoke airlplain=metal+bird alcohol=fruit+time algae=plant+water allergy=dust+human alligator=swamp+lizard angel=human+bird antarctica=desert+snow aquarium=glass+water archipelago=isle+isle armor=metal+tool ash=energy+volcano ast…
原文转自:http://www.smashingmagazine.com/2014/11/03/styling-and-animating-svgs-with-css/?utm_source=CSS-Weekly&utm_campaign=Issue-135&utm_medium=email CSS can be used to style and animate scalable vector graphics, much like it is used to style and ani…