Hide

Problem D
Gears and Axles

You have an assortment of circular gears with varying numbers and sizes of teeth. You also have a motor that spins at one revolution per second, as well as an unlimited number of (identical, arbitrarily long) axles. The motor and all gears fit the axles, and everything attached to a particular axle rotates at the same angular speed. Two gears with the same size teeth can be enmeshed with each other. Gears with different size teeth cannot be enmeshed with each other (though they can be placed on the same axle).

\includegraphics[width=0.50\textwidth ]{gears.jpg}

You can arrange the gears and axles in any order. What is the maximum rate at which the last gear/axle in sequence spins that you can achieve? Because this may be large, output the natural log of the value.

Input

The first line of input contains a single integer $n$ ($0 \le n \le 10^5$) denoting the number of gears.

Each of the next $n$ lines contains two integers $s$ ($1 \le s \le 10^5$) and $c$ ($3 \le c \le 10^5$), one for each gear in your collection, where $s$ is the size of the teeth of the gear and $c$ is the count of the number of teeth.

Output

Output a single line with a single number equal to the natural log of the maximum angular speed you can achieve with your motor and axles and gears in your collection. This output will be considered correct if it is within an absolute or relative error of $10^{-6}$ .

Sample Input 1 Sample Output 1
6
19 364
21 1023
19 66
19 242
21 807
19 675
2.9704451880078357
Sample Input 2 Sample Output 2
4
33 10
33 27
44 10
44 27
1.9865035460205664

Please log in to submit a solution to this problem

Log in