您的位置:首页 > 其它

POJ_3101_Astronomy

2013-08-21 14:51 309 查看
Astronomy

Time Limit: 2000MSMemory Limit: 65536K
Total Submissions: 4468Accepted: 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



Source

Northeastern Europe 2005, Northern Subregion

题型:数论(高精度+素因子分解)

题意:(一开始看见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 约分即得最终答案
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: