ZOJ 3203 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
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h> using namespace std;
double h,H,d;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf",&H,&h,&d);
double x=sqrt((H-h)*d);
double x2=d*h/H;
double l=(H-h)*d/H;
double ans;
if(x>l&&x<d)
ans=H+d-(2*(sqrt((H-h)*d)));
else
ans=max(x2,h);
printf("%.3f\n",ans); }
return 0;
}
ZOJ 3203 Light Bulb的更多相关文章
- 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 - 求导求最大值
		
如果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 (三分查找)
		
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
 - ZOJ 3203 Light Bulb(数学对勾函数)
		
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
 - [清华集训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$时,人在墙上的影子 ...
 
随机推荐
- 如果分配给命令的连接位于本地挂起事务中,ExecuteNonQuery 要求命令拥有事务。命令的 Transaction 属性尚未初始化
			
DbConnection dbc = database.CreateConnection(); DbTransaction dbtt = null; try { dbc.Open(); dbtt = ...
 - 视差滚动(Parallax Scrolling)插件补充
			
13. Windows Windows (github) 是一个让你用占据整个屏幕的section来构建单面网站的插件.该插件提供给你一些回调函数,当新的section出现在可视区并且并且处理快照时被 ...
 - nodejs基础 -- buffer缓冲区
			
JavaScript 语言自身只有字符串数据类型,没有二进制数据类型.但在处理像TCP流或文件流时,必须使用到二进制数据.因此在 Node.js中,定义了一个 Buffer 类,该类用来创建一个专门存 ...
 - linux -- ubuntu 脚本开机自启动
			
有一个脚本想在ubuntu 虚拟机开机时,自动运行. 创建脚本文件 在“/opt/lampp/”下新建一个脚本文件:lampp_start.sh #!/bin/bash /opt/lampp/lamp ...
 - Shader开发之三大着色器
			
固定功能管线着色器Fixed Function Shaders 固定功能管线着色器的关键代码一般都在Pass的材质设置Material{}和纹理设置SetTexture{}部分. Shader &qu ...
 - Json序列化问题
			
之前Json字符反序列化为C#对象时 总是写一个实体类.. 如:{"a":5,"b":10} 这种json字符串 对应的实体类为: public class R ...
 - 【Java面试题】24  sleep() 和 wait() 有什么区别?  详细解析!!!!
			
第一种解释: 功能差不多,都用来进行线程控制,他们最大本质的区别是:sleep()不释放同步锁,wait()释放同步缩. 还有用法的上的不同是:sleep(milliseconds)可 ...
 - 【MongoDB】数组长度查询
			
db.groupedInfo.count({'surveyInfo.surveyAndUserID.0':{$exists:1}})
 - MVC+LINQToSQL的Repository模式之(二)数据基类
			
namespace Data.TEST{ /// <summary> /// 数据操作基类 /// </summary> public abstract ...
 - 移植opencv到pcDuino
			
OpenCV是一个基于(开源)发行的跨平台计算机视觉库,可以运行在Linux.Windows和Mac OS操作系统上.它轻量级而且高效——由一系列 C 函数和少量 C++ 类构成,同时提供了Pytho ...