如果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 t;
scanf("%d",&t);
while(t--){
scanf("%lf%lf%lf",&H,&h,&D);
x0 = D - h * D / H;
x = sqrt( D * (H - h) );
y = (D - x) * (H - h) / x;
if(x >= D) printf("%.3lf\n",h);
else if(x < x0) printf("%.3lf\n",h * D / H);
else printf("%.3lf\n",h - y + D - x);
}
return ;
}

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 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

ZOJ 3203 Light Bulb - 求导求最大值的更多相关文章

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

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

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

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

  3. 三分 --- ZOJ 3203 Light Bulb

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

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

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

  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. ZOJ 3203 Light Bulb

    Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow a ...

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

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

  9. ZOJ - 3203 Light Bulb(三分)

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

随机推荐

  1. PGA_AGGREGATE_TARGET 原理

    PGA_AGGREGATE_TARGET参数的理解 PGA结构图:                                   在Oracle9i之前,PGA的计算和控制都是比较复杂的事情,从 ...

  2. app微信支付服务器端php demo

    class Wxpay { /* 配置参数 */ private $config = array( 'appid' => "wxc92b12277f277355", /*微信 ...

  3. 08-C语言循环

    目录: 一.for循环 二.break,continue 三.循环嵌套 四.while 五.do while 六.三个循环的对比 七.空语句 回到顶部 一.for循环 标识每次循环,循环终止条件,循环 ...

  4. IT项目经理

    项目经理是具体项目工作的管理者,他们在工作中不断提升自己的领导才华,同时该职业又是一个权利与责任并存的职业, 他们主要对项目进行背景调查,收集整理项目相关资料,进行需求策划,撰写项目调查报告和信息综述 ...

  5. delphi 编译生成ipa文件

    找IPA文件 开发模式ipa文件和发布模式ipa文件,路径不同. http://www.itnose.net/detail/6101808.html 一.开发模式Development 不需要真机,可 ...

  6. JavaScript闭包理解的关键 - 作用域链

    阮一峰的一篇文章已经对闭包的用途.概念讲解地相对清晰了. 闭包就是能够读取其他函数内部变量的函数. 但我认为里面对于作用域链的解释还不够清晰,这里作一些补充. 闭包之所以可以读取外部函数的内部变量,即 ...

  7. 最新VMware Workstation 10注册码,绝对可用!

    最近公司要在solaris上测试产品,需要用到虚拟机,于是下载了最新的虚拟机VMware Workstation 10,并找到了破解码,与大家共享: VMware workstation 10破解序列 ...

  8. openstack之Nova

    一.Nova简介及其核心组件: Nove在openstack中提供计算服务: Nova核心模块: Controller Nova-api:提供API,包括命令行API; Nova-schedule: ...

  9. HTML+CSS基础总结

    1. 首先声明正确的文档类型doctype 通常有四种文档类型可供选择: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ...

  10. man命令重定向后有^H乱码问题

    在  man ld.so>ld.so后 vim打开ld.so后出现重叠乱码问题 但是cat.less可以正常查看 解决办法:  man ld.so|col -b >ld.so col命令是 ...