P5931 [Tsinghua Training 2015] Light Bulb

Background

In $2022$, the judging testdata changed a lot. Please ask anyone who passed this problem before $2022$ to submit again.

Description

Compared with Wildleopard’s home, his younger brother Mildleopard is poorer. His house is narrow, and there is only one light bulb in his room. Every night, he walks around in his small house, thinking about how to earn more money. One day, he found that the length of his shadow changes as he walks between the light bulb and the wall. A sudden idea came to his mind: he wants to know the maximum possible length of his shadow in the room. ![](https://cdn.luogu.com.cn/upload/image_hosting/i78578mk.png)

Input Format

The first line contains an integer $T$, the number of test cases. For each test case, there is one line containing three real numbers $H$, $h$, and $D$. $H$ is the height of the light bulb, $h$ is Mildleopard’s height, and $D$ is the horizontal distance between the light bulb and the wall.

Output Format

Output $T$ lines. For each test case, output one line with the maximum shadow length $L$. Your answer is accepted if the absolute error compared with the standard output is at most $10^{-3}$.

Explanation/Hint

Constraints: $1 \le T \le 100$, $0.01 \le H, h, D \le 1000$, $H - h \ge 0.01$. It is guaranteed that $H$, $h$, and $D$ have at most $6$ digits after the decimal point. Translated by ChatGPT 5