POJ_3101_Astronomy

Astronomy
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

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 约分即得最终答案

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值