A. Light Bulb
A. Light Bulb
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 解题:好吧,比较喜欢数学解法,速度快嘛。。。参阅某神的代码。。。
算法:利用函数的凸性
思路一:
学妹的思路:三分 L
#include<stdio.h>
#include<string.h>
#include<math.h> int main()
{
int T;
double H,h,D;
scanf("%d", &T);
while(T--)
{
scanf("%lf%lf%lf", &H,&h,&D);
double x1 = (H-h)*D/H;
double x2 = D;
double x0 = sqrt(D*(H-h)); double x; if(x1 <= x0 && x0 <= x2) x = x0;
else if(x0 <= x1) x = x1;
else if(x0 >= x2) x = x2; double ans = D+H- (x + (H-h)*D/x);
printf("%.3lf\n", ans);
}
return ;
}
A. Light Bulb的更多相关文章
- 三分 --- ZOJ 3203 Light Bulb
Light Bulb Problem's Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: ...
- Light Bulb(三分)
ZOJ Problem Set - 3203 Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildl ...
- 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 (三分+计算几何)
B - Light Bulb Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit ...
- 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 ...
- TOJ 2814 Light Bulb
Description Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house ...
随机推荐
- 公司开发部门GIT与SVN 之争
公司最开始决定是使用GIT作为版本控制 , 也都使用了4,5个月了 , 开发人员也都是20多岁年轻力壮的年轻人 , 每个组的组长也一直在做git使用的培训 , 即使是这样 , 还是遇到了非常大的阻碍 ...
- Mysql order by 多字段排序
mysql单个字段降序排序: select * from table order by id desc; mysql单个字段升序排序: select * from table order by id ...
- Django分组查询
先补充两个知识点: 1.group by 大前提:可以按照任意字段分组,但是最好是按照分辨度比较低的来分组(重复比较多的分辨度比较低). group by分组可以单独使用,不搭配其他条件. 分组的字段 ...
- CF895 E. Eyes Closed(线段树 期望)
题意 Sol 今天考试的T3,,我本来留了一个小时去写.但是T2一刚就刚了两个小时 最后也没来的及写.. 然后考完 开始写,,25min就A了.. 感觉自己太高估自己的思维,太低估自己的码力了... ...
- nmon各配置项含义介绍
1)nmon各配置项含义介绍
- 基于Vmware player的Windows 10 IoT core + RaspberryPi2安装部署
本文记录了基于Vmware Player安装Windows10和VS2015开发平台的过程,以及如何在RaspberryPi2.0上启动Windows10 IoT core系统,并通过一个简单的hel ...
- Tensorflow_入门学习_2_一个神经网络栗子
3.0 A Neural Network Example 载入数据: from tensorflow.examples.tutorials.mnist import input_data mnist ...
- WPF中单选框RadioButton
单选框RadioButton的基本使用: <StackPanel Margin="10"> <Label FontWeight="Bold"& ...
- 关于highchts X时间轴比设置时间相差好几个小时的解决
经过一番查询和研究发现,在曲线图里,x轴的UNIX时间戳是要乘以1000的(通过在线的UNIX转换,结果与原来没有乘以1000的时间戳相差甚远),不然显示的时间会有很大的误差,真是百思不得其解. 另外 ...
- C#在透明窗体WinForm上面画图(电子尺小工具的实现)
前几天要做一个微信调一调的外挂,里面用到了尺子测量距离,然后就自己下载了一个电子尺,最近要升级我的跳一跳外挂,然后就准备自己做一个电子尺,嵌入到我的外挂里面,在嵌入到我的外挂之前,我自己做了一个完整版 ...