Amphitheatre X03147


Statement
 

pdf   zip

html

Measharans like to attend plays and concerts which take place in amphitheatres. Artists perform on a stage, which is a semicircle of radius r meters. Guests take their places in rows, which are concentric semicircles around the stage; i-th row has a radius of r+(i−1) meters. Each row is divided into d equal sectors.

It is possible to move in two ways: move along a row (clockwise or counter-clockwise), at a speed of vr meters per minute; or along one of d+1 sector boundaries, at a speed of vd (downwards, i.e., towards the stage) or vu (upwards) meters per minute.

The amphitheatres are planning to create an online system for booking seats. However, when booking for a group, it is sometimes impossible to make all the group sit together, but it is important to make it easy for the group members to reach each other. Your task is to calculate the time required to travel between two given seats.

Input

Input consists of several cases. Each case is a single line containing nine integers: r (radius of the stage), d (number of sectors), vr, vd, vu (speeds, as defined above), s1 (the row number of the first seat), φ1 (the position of the first seat on the semicircle, given in degrees), s2, φ2 (row number and position of the second seat). We have 1 ≤ r ≤ 1000, 1 ≤ d ≤ 1000, 1 ≤ vr, vd, vu ≤ 100, 1 ≤ s1,s2 ≤ 1000, 0 ≤ φ1, φ2 ≤ 180.

Input ends with a line containing 9 zeros.

Output

For each input case output a single number – the number of minutes required to travel from the first seat to the second seat, rounded to exactly three decimal places.

In the first case, we need to traverse the whole first row, which is a semicircle of radius 100. The speed is 3 m/min, so we need 100π/3 minutes.

In the secord case, we are sitting at a sector boundary, so it is enough to climb 10 meters at speed 5 m/min. The third case is similar, except that we are descending now.

In the fourth case, we are not able to climb directly, since we are not sitting at a degree boundary. We need to go 5 degrees to the sector boundary (at 75 degrees), climb 1 meter, and go 5 degrees back.

The last two cases return very small values.

Public test cases
  • Input

    100 12 3 7 5 1 0 1 180
    100 12 3 7 5 1 90 11 90
    100 12 3 7 5 11 90 1 90
    100 12 3 7 5 2 70 1 70
    1 12 100 100 100 1 0 1 1
    1 12 10 10 10 1 0 1 1
    0 0 0 0 0 0 0 0 0
    

    Output

    104.720
    2.000
    1.429
    5.990
    0.000
    0.002
    
  • Information
    Author
    Eryk Kopczynski
    Language
    English
    Official solutions
    Unknown.
    User solutions
    C++