lightoj1062

maksyuki 发表于 oj 分类,标签:
0

1062 - Crossed Ladders

InputA narrow street is lined with tall buildings. An x foot long ladder is rested at the base of the building on the right side of the street and leans on the building on the left side. A y foot long ladder is rested at the base of the building on the left side of the street and leans on the building on the right side. The point where the two ladders cross is exactly c feet from the ground. How wide is the street?

Input starts with an integer T (≤ 10), denoting the number of test cases.

Each test case contains three positive floating point numbers giving the values of xy, and c.

Output

For each case, output the case number and the width of the street in feet. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

430 40 1012.619429 8.163332 310 10 3

10 10 1

Case 1: 26.0328775442Case 2: 6.99999923Case 3: 8Case 4: 9.797958971

 

 

题目类型:二分

算法分析:直接手算得出求c的公式,然后二分枚举胡同的宽度即可,注意二分枚举的开始区间为[0, min (a,b)]!!!!!!