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

#BS0000386. Cầu treo (Suspension Bridges)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Cầu treo (Suspension Bridges)

Suspension Bridges

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

A mountain village plans a suspension bridge over a gorge. The two cable anchors are at equal elevation and horizontal distance dd apart. The cable’s lowest point is midway between the anchors and ss below them. A freely hanging cable forms a catenary, with a positive parameter aa satisfying

a+s=acosh⁡(d2a).a+s=a\cosh\left(\frac{d}{2a}\right).

The cable length is ℓ=2asinh⁡(d/(2a))\ell=2a\sinh(d/(2a)), where sinh⁡x=(ex−e−x)/2\sinh x=(e^x-e^{-x})/2 and cosh⁡x=(ex+e−x)/2\cosh x=(e^x+e^{-x})/2. Compute the required cable length.

Input

One line contains integers d,sd,s, the horizontal anchor separation and the central sag.

Output

Print the cable length. The absolute error must not exceed 10−410^{-4}.

Subtasks

  • Subtask 1 (20 points): 1≤d,s≤10001\le d,s\le1000; d=sd=s.
  • Subtask 2 (30 points): 1≤d,s≤10001\le d,s\le1000; s≤ds\le d.
  • Subtask 3 (50 points): 1≤d,s≤10001\le d,s\le1000.

Examples

Input

400 40

Output

410.474747252

Explanation

The anchors are 400 apart and the sag is 40. The parameter satisfies a+40=acosh⁡(200/a)a+40=a\cosh(200/a). Its approximate value is a=506.53a=506.53. Substitution into 2asinh⁡(200/a)2a\sinh(200/a) gives approximately 410.474747252.