如果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. KVO 的使用和举例

    KVO(key-value Observer),通过命名可以联想到,一个监视着监视着键值配对,让一个对象A来监视另一个对象B中的键值,一旦B中的受监视键所对应的值发生了变化,对象A会进入一个回调函数, ...

  2. IT项目经理

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

  3. Struts2 中action之间的跳转(分享)

    例如从你的login.action到register.action  有两种实现方式 1. 设置type="redirect" <package  name="st ...

  4. C++中struct和class的总结

    一.在语法上的一些区别 由于C++是从C发展而来,C++中的struct更多的是去做了兼容的C的部分.在语法层面他们有以下的区别: 1. struct中所有的成员是是public,也就是说你可以对一个 ...

  5. Sicily-1028

    一.        题意: 算出汉诺塔移动序列中对应位置的号码,数据规模很大,所以不能单纯递归,而是要找出汉诺塔序列的规律. 二.        汉诺塔数列 为了得出最少的移动步数,当n为偶数时,最上 ...

  6. IPhone多视图切换

    处理IPhone多个view切换是我们常遇到的问题,接下来有个比较实用的方法: 而且还附有创建空项目,内存告急处理和动画效果的实现! 具体步骤: 1.创建一个空的项目,然后添加一个ViewContro ...

  7. JAVA知识的相关积累--用于自己以后查找

    基础: Properties类操作文件,主要是对配置文件的操作.java中的properties文件是一种配置文件,主要用于表达配置信息,文件类型为*.properties,格式为文本文件,文件的内容 ...

  8. URAL 1225 Flags

    题目:click here #include <bits/stdc++.h> using namespace std; typedef long long ll; ; int n; ll ...

  9. debian下samba配置

    debian下samba配置  http://blog.chinaunix.net/uid-2282111-id-2113216.html 服务器端配置过程:1. apt-get install sa ...

  10. uml笔记

    把进度放在好了: 活动图与业务流程 对业务流程支持的主要图形就是活动图,活动图的主要目的在陈述活动与活动之间流程控制的转移.