PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000378. Hai thang bắt chéo (Crossed Ladders)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Hai thang bắt chéo (Crossed Ladders)

Crossed Ladders

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Tall buildings stand along opposite sides of a street. A ladder of length xx feet rests at the foot of the right wall and leans against the left wall. A ladder of length yy feet is placed in the opposite direction. Their crossing point is cc feet above the ground. Find the horizontal distance between the walls.

Crossed ladders

Input

One line contains three positive real numbers x,y,cx,y,c, measured in feet.

Output

Print the width of the street in feet rounded to exactly three decimal places.

Subtasks

  • Subtask 1 (20 points): 0<x,y,c≤1060<x,y,c\le10^6; c<xyx+yc<\frac{xy}{x+y}. All three numbers are integers and x=yx=y.
  • Subtask 2 (30 points): 0<x,y,c≤1060<x,y,c\le10^6; c<xyx+yc<\frac{xy}{x+y}. All three numbers are integers.
  • Subtask 3 (50 points): 0<x,y,c≤1060<x,y,c\le10^6; c<xyx+yc<\frac{xy}{x+y}. Each number has at most 6 digits after the decimal point.

Examples

Input

10 10 3

Output

8.000

Explanation

The equal ladders meet above the midpoint, and each upper endpoint has height 2c=62c=6. By the Pythagorean theorem the width is 102−62=8\sqrt{10^2-6^2}=8.

Input

10 10 1

Output

9.798

Explanation

Both upper endpoints have height 2 feet. The width is 100−4=96≈9.797959\sqrt{100-4}=\sqrt{96}\approx9.797959, rounded to 9.7989.798.

Input

30 40 10

Output

26.033

Explanation

At width 26.03326.033, the endpoint heights are about 900−26.0332\sqrt{900-26.033^2} and 1600−26.0332\sqrt{1600-26.033^2} feet. Their product divided by their sum gives a crossing height of about 10 feet. The unique matching width rounds to 26.033.

Input

12.619429 8.163332 3

Output

7.000

Explanation

For width 7 feet the endpoint heights are approximately 10.5 and 4.2 feet. The crossing height is 10.5⋅4.2/(10.5+4.2)=310.5\cdot4.2/(10.5+4.2)=3 feet. With the given input precision, the width rounds to 7.000.