Light BulbTime 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, thinking of how to earn more money. One day, he found that the length of his shadow was changing from time to time while walking between the light bulb and the wall of his house. A sudden thought ran through his mind and he wanted to know the maximum length of his shadow.
Input
The first line of the input contains an integer T (T <= 100), indicating the number of cases.
Each test case contains three real numbers H, h and D in one line. H is the height of the light bulb while h is the height of mildleopard. D is distance between the light bulb and the wall. All numbers are in range from 10-2 to 103, both inclusive, and H - h >= 10-2.
Output
For each test case, output the maximum length of mildleopard's shadow in one line, accurate up to three decimal places..
Sample Input
3
2 1 0.5
2 0.5 3
4 3 4
Sample Output
1.000
0.750
4.000
Author: GUAN, Yao
Source: The 6th Zhejiang Provincial Collegiate Programming Contest
#include
#include
#include
using namespace std;
int t;
double h,H,D;
int main()
{
while(~scanf("%d",&t))
{
for(;t>;t--)
{
scanf("%lf%lf%lf",&H,&h,&D);
//最优解在[x0,x2]之间,如果能取到x1,则影子最长
//影子长度在此区间内,符合倒钩函数l=H+D-x-D*(H-h)/x
double x0=D*(H-h)/H;//在墙壁上的影子长度为0时,人与灯的距离
double x1=sqrt(D*(H-h));
double x2=D;//人不断向后移(也就是向墙壁移动),最远到墙壁,人与灯的距离
double x;
if (x0<=x1 && x1<=D) x=x1; //区间包含x1
else if(x2<=x1) x=x2;//区间在x1的左边,即最大值小于x1
else if(x0>=x1) x=x0;//区间在x1的右边,即最小值大于x1
printf("%.3lf\n",H+D-x-D*(H-h)/x);
}
}
return ;
}
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 (三分查找)
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
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
Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow a ...
[清华集训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 ...
ZOJ - 3203 Light Bulb(三分)
题意:灯离地面的高度为$H$,人的身高为$h$,灯离墙的距离为$D$,人站在不同位置,影子的长度不一样,求出影子的最长长度. 思路:设人离灯的距离为$x$,当人走到距离灯长度为$L$时,人在墙上的影子 ...
随机推荐
Minor【 PHP框架】4.服务容器与服务提供者
框架Github地址:github.com/Orlion/Minor (如果觉得还不错给个star哦(^-^)V) 框架作者: Orlion 知乎:https://www.zhihu.com/peop ...
openwrt 更改默认主题
BB 版本默认的主题为 bootstrap,想要修改为其他的主题,可以按照如下方法修改: 1.查看可以使用的主题. "make menuconfig" ---> " ...
Redis构建分布式锁
1.前言 为什么要构建锁呢?因为构建合适的锁可以在高并发下能够保持数据的一致性,即客户端在执行连贯的命令时上锁的数据不会被别的客户端的更改而发生错误.同时还能够保证命令执行的成功率. 看到这里你不禁要 ...
svn状态与常见错误
TortoiseSVN 1.6.16是最后一个目录独立管理自身cache的svn版本(每个目录下都有一个隐藏的.svn文件夹) 之后的版本会则会根目录上统一进行管理(只有根目录下有一个隐藏的.svn文 ...
jenkins(5): jenkins邮件报警配置
参考: https://blog.csdn.net/u013066244/article/details/78665075 1. 使用 增强版的邮件通知 1.1 安装插件 1.2. 系统配置 ...
LeetCode83.删除排序链表中的重复的元素
给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次. 示例 1: 输入: 1->1->2 输出: 1->2 示例 2: 输入: 1->1->2->3-&g ...
python 阿狸的进阶之路(5)
一.模块 1.什么是模块: 包含了一组功能的python文件,文件名是xxx.py,模块名是module. 可以使用 import module,四个通用的类别: (1)用python编写的py文件 ...
embOS实时操作系统 - 任务状态
A task may be in one of several states at any given time. When a task is created, it is placed into ...
【微信小游戏】文件系统,远程加载资源打破4M限制
一.前提 微信小游戏,对游戏包体的大小有严格是限制,上传文件大小<4M,但是本地缓存文件有50M空间,也就是说我们可以将一些资源放到网上,然后缓存到本地. 二.官方概念 文件系统 文件系统是小程 ...
【面试季之三】IE6兼容问题
最近面试真的碰到很多基础的问题,平时在工作的时候往往可以直观的看到页面的问题,然后进行代码调试,调试不明白了还可以上网查一下.可是面试的时候,就是得当场反应出来,并且还得能系统的说出1.2.3.4.5 ...