Conic Distance#1501

Conic Distance

1 second
64 megabytes
Hard

A cone is located in D space such that its base of radius lies in the z = 0 plane, with its center at (0, 0, 0). The tip (vertex) of the cone is at (0, 0, h). Two points are given on the surface of the cone in conic coordinates.

The conic coordinates of a point on the surface of the cone are described by a pair , where is the distance from the tip of the cone to , and (A < 360) is the angle in degrees between the plane y = 0 and the plane passing through (0, 0, 0), (0, 0, h) and , measured counterclockwise from the direction of the -axis.

Given two points p_1 = (d_1, A_1) and p_2 = (d_2, A_2) in conic coordinates, find the shortest distance between p_1 and p_2 measured along the surface of the cone.

Input

Each line is a separate test case and contains real numbers: , , d_1, A_1, d_2, A_2.

Output

For each test case, print the shortest distance between p_1 and p_2 on the surface of the cone, rounded to decimal places, on a separate line.

Examples

Example 1

Loading
Loading