TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

An apple has the shape of a perfect sphere with the radius equal to 1. There is

a worm located at some point A on the surface of the apple. The worm wants to
move to the point B, also located on the surface of the apple. The worm may move
in two fashions:


- to crawl along the surface of the apple with the constant speed v0;

- to gnaw a wormhole in the shape of a straight line segment from point A to
point B.


The inside of the apple consists of a core surrounded by the pulp. The core of
the apple is also a perfect sphere, with the radius equal to P , and the center in the
center of the whole apple. The worm can gnaw through the core with the speed v 1
and through the pulp with the speed v 2.


Determine the minimal time the worm needs to get from the point A to the
point B. The size of the worm can be neglected.

Input Format

each testcase consists of three lines. The first line contains
the values of P (0 < P < 1, the value is given with up to 3 decimal places), v0, v1,
and v2 (integers in the range from 1 to 100). The second and the third line give the
points A and B, respectively, as two angles in the spherical coordinate system. The
first angle, the azimuth φ (0 ≤ φ < 360°), gives the angle between the X axis and
the projection on the XY plane of the segment connecting the origin to the
corresponding point. The second angle, the polar θ (0 ≤ θ ≤ 180°), gives the angle
between the Z axis and the segment connecting the origin to the corresponding
point. The values φ and θ are integers and given in degrees. In all test cases where
θ = 0 or θ = 180, φ is given as 0.

Output Format

for each case should contain
the minimal time of travel, accurate to 10-9.

Sample Input 1

0.5 10 15 20
0 0
0 180
0.5 20 5 2
0 0
0 180

Sample Output 1

0.116666667
0.157079633

Hints

Problem Source

Migrated from old NTUJ.

icpc2008, neerc west

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 10000 65536 200