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 Hh 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的更多相关文章

  1. ZOJ 3203 Light Bulb (三分+计算几何)

    B - Light Bulb Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit ...

  2. 三分 --- ZOJ 3203 Light Bulb

    Light Bulb Problem's Link:   http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: ...

  3. ZOJ 3203 Light Bulb - 求导求最大值

    如果L全在地面上: 输出 h * D / H 如果L全在墙上: 输出 h 否则: (D - X ) / X = Y / (H - h) L = D - X + h - Y 然后对L求导即可 #incl ...

  4. zoj 3203 Light Bulb,三分之二的基本问题

    Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...

  5. ZOJ 3203 Light Bulb (三分查找)

    Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...

  6. ZOJ 3203 Light Bulb(数学对勾函数)

    Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...

  7. [清华集训2015]灯泡(浙江大学ZOJ 3203 Light Bulb)

    Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, his brother ...

  8. ZOJ 3203 Light Bulb( 三分求极值 )

    链接:传送门 题意: 求影子长度 L 的最大值 思路:如果 x = 0 ,即影子到达右下角时,如果人继续向后走,那么影子一定是缩短的,所以不考虑这种情况.根据图中的辅助线外加相似三角形定理可以得到 L ...

  9. ZOJ - 3203 Light Bulb(三分)

    题意:灯离地面的高度为$H$,人的身高为$h$,灯离墙的距离为$D$,人站在不同位置,影子的长度不一样,求出影子的最长长度. 思路:设人离灯的距离为$x$,当人走到距离灯长度为$L$时,人在墙上的影子 ...

随机推荐

  1. Spring 4 官方文档学习(七)核心技术之Spring AOP APIs

    请忽略本篇内容!!! 1.介绍 2.Spring中的pointcut API 2.1.概念 2.2.对pointcut的操作 2.3. AspectJ expression pointcut 2.4. ...

  2. Zookeeper leader选举

    让我们分析如何在ZooKeeper集合中选举leader节点.考虑一个集群中有N个节点.leader选举的过程如下: 所有节点创建具有相同路径 /app/leader_election/guid_ 的 ...

  3. find_circ 识别circRNA 的原理

    find_circ 通过识别junction reads 来预测circRNA 和参考基因组比对完之后,首先剔除和基因组完全比对的reads,保留没比对上的reads, 这部分reads 直接比是比对 ...

  4. php 错误和异常处理

    一.错误和异常处理 1.1 错误类型和基本的调试方法 PHP程序的错误发生一般归属于下列三个领域: 语法错误: 语法错误最常见,并且也容易修复.如:代码中遗漏一个分号.这类错误会阻止脚本的执行. 运行 ...

  5. 搜集的一些酷炫的金属色 ,RGB值 和大家分享一下

    开发iOS程序过程中会使用到RGB,要注意每个RGB值都要除以 255.0 ,注意: ' .0 ' 不能省!! 一下是本人搜集的一些酷炫金属色的RGB值:   黄金 242,192,86 石墨 87, ...

  6. Linux 快速删除大量小文件方法

    进行以下两步操作即可: 1.第一步:创建空的文件夹: mkdir  /tmp/blank 2.第二步:执行以下命令:rsync --delete-before -d /tmp/blank/ /home ...

  7. 帝国CMS7.2新增多图同时上传插件,上传多图效率更高

    原来上传多图文件,需要挨个选择文件,然后再点批量上传,比较麻烦.所以帝国CMS7.2新增了多图上传插件:为采用FLASH方式实现同时选择多个图片一起上传,提高多图上传效率. 帝国CMS多图上传插件特性 ...

  8. 查看当前mysql数据库实例中,支持的字符集有哪些,或者是否支持某个特定字符集

    需求描述: 查看当前mysql实例中支持哪些字符集,过滤特定的字符集 操作过程: 1.通过show character set来进行查看 mysql> show character set; + ...

  9. RedisTemplate实现事物问题剖析和解决

    一.问题描述 Redis为单进程单线程模式,采用队列模式将并发访问变成串行访问,Redis对事物支持不会很复杂,当一个客服端连接Redis服务时,发出了MULTI命令时,这个连接会进入事物,在执行MU ...

  10. [转]ASP.NET MVC 5 - 查询Details和Delete方法

    在这部分教程中,接下来我们将讨论自动生成的Details和Delete方法. 查询Details和Delete方法 打开Movie控制器并查看Details方法. public ActionResul ...