Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 4468 | Accepted: 951 |
Description
There are n planets in the planetary system of star X. They orbit star X in circular orbits located in the same plane. Their tangent velocities are constant. Directions of orbiting of all planets are the same.
Sometimes the event happens in this planetary system which is called planet parade. It is the moment when all planets and star X are located on the same straight line.
Your task is to find the length of the time interval between two consecutive planet parades.
Input
The first line of the input file contains n — the number of planets (2 ≤ n ≤ 1 000).
Second line contains n integer numbers ti — the orbiting periods of planets (1 ≤ ti ≤ 10 000). Not all of ti are the same.
Output
Output the answer as a common irreducible fraction, separate numerator and denominator by a space.
Sample Input
3 6 2 3
Sample Output
3 1
Hint
![](https://i-blog.csdnimg.cn/blog_migrate/677a0cf854675aa73f8cbbcb9795dde9.gif)
Source
题型:数论(高精度+素因子分解)
题意:(一开始看见Hint,我还以为是写轮眼。。。)给出一批行星的周期,问连续两次所有行星连成一线的时间。
分析:
相差半周期的时间:d [ i ] * d [ i+1 ] / ( 2 * abs ( d [ i+1 ] - d [ i ] ) )
设bi = d [ i ] * d [ i+1 ] , ai = 2 * abs ( d [ i+1 ] - d [ i ] )
设:T[ i ] = bi / ai
则就是求T[ i ]的最小公倍数
分母p=gcd(a1,a2,...,an-1)
分子q=lcm(b1,b2,...,bn-1)
q / p 约分即得最终答案