#P6322. Rotating Rings

    ID: 19538 Type: Default 1000ms 256MiB

Rotating Rings

Rotating Rings

There are n rings, each with a different radius, arranged in a line on the ground. The rings are placed in such a way that, except for the first and the last rings, every ring touches its two adjacent rings. When the first ring rotates exactly 1 full turn, determine how many full turns each of the other rings makes.

When two rings with radii \(r_i\) and \(r_j\) are externally tangent, the condition for no slipping at the point of contact implies that the arc lengths are equal. Thus, if the \(i^{th}\) ring rotates by \(\theta_i\) turns, then the adjacent \(j^{th}\) ring rotates \(\theta_j\) turns such that:

[ r_i \times \theta_i = r_j \times \theta_j, ]

Taking into account the change in rotational direction (adjacent rings rotate in opposite directions), if the first ring rotates 1 turn, then for every \(i \ge 2\) the number of turns of the \(i^{th}\) ring is given by:

[ \theta_i = (-1)^{i-1} \frac{r_1}{r_i}, ]

Since the answers may not be integers, output the answer as an irreducible (simplest form) fraction in the format p/q (see sample for the exact format).

inputFormat

The input consists of two lines. The first line contains a single integer n (\(2 \leq n \leq 10^5\)), the number of rings. The second line contains n positive integers \(r_1, r_2, \dots, r_n\) representing the radii of the rings in order.

outputFormat

For each ring from the second to the last (i.e., for \(i = 2, 3, \dots, n\)), output one line containing the number of turns it rotates, represented as an irreducible fraction in the format p/q. If the result is negative, the negative sign should appear in front of the numerator.

sample

3
4 2 6
-2/1

2/3

</p>