Author: | NEERC-2008 Jury | Time limit: | 2 sec | |
Input file: | clock.in | Memory limit: | 64 Mb | |
Output file: | clock.out |
One famous Russian architect plans to build a new monumental construction. It will be a huge clock that indicates the time from the beginning of the universe.
The face of this clock contains hands, moving at constant speeds. They are numbered from 1 to n from the fastest to the slowest one. The fastest hand makes one revolution per minute (60 seconds). Each next hand moves slower than previous, the (i+1)-th hand makes one revolution when the i-th hand makes di revolutions. The setting mechanism of this clock is very simple. You can take a hand by the handle, located on its end, and move it in any direction. When you move the hand, slower hands are moving in proportion to their usual speeds, and faster hands are not moving. Remember that hands are huge, so setting this clock is a hard job. Consider an example with three hands: a second hand, a minute hand, and an hour hand. Their lengths are 5, 15 and 10 meters respectively. You want to set the clock from 2:30 to 6:00 (fig.1). The easiest way to do it is to rotate the minute hand 180∘ clockwise, and then move the hour hand 90∘ clockwise. The total distance you moved the handles of the hands is approximately 62.83 meters. Your task is to write a program that finds the way to set the clock that minimizes the total distance you have to move the handles.0 < n ≤ 50
2 ≤ di ≤ 106
1 ≤ li ≤ 106
No. | Input file (clock.in ) |
Output file (clock.out ) |
---|---|---|
1 |
|
|