zoj 3203 Light Bulb (三分)

来源:互联网 发布:淮南市农村残疾人数据 编辑:程序博客网 时间:2024/06/05 10:56

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

32 1 0.52 0.5 34 3 4

Sample Output

1.0000.7504.000
求人从左向右走动时,影子的长度L的最大值

人在灯下的影子长度是0,这时他如果向前走的话,影子会逐渐变长,到最后人走到墙的位置的时候,影长度便是人的身高了,所以影长的变化曲线要么是单调递增的,要么是向上凸的,所以适合三分。(二分法作为分治中最常见的方法,适用于单调函数,逼近求解某点的值当函数是凸性函数时,就得用三分)。

由于影长从灯下0一直到恰好没投影到墙上的过程是一个单调的过程,我们可以把这段忽略,直接求解,投影到墙上后,影长的变化即可。





0 0