POJ_3101_Astronomy
2013-08-21 14:51
309 查看
Astronomy
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
Sample Output
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 约分即得最终答案
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 4468 | Accepted: 951 |
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 约分即得最终答案
相关文章推荐
- poj 3101 Astronomy——求分数的最小公倍数
- poj 3101 Astronomy (java 分数的最小公倍数 gcd)
- poj_3101 Astronomy(大整数+分数最小公倍数)
- POJ 3101 Astronomy (数学)
- poj 3101 Astronomy
- POJ 3101 Astronomy
- poj 3101 Astronomy (GCD LCM 高精度)
- POJ 3101 Astronomy (挖坑待学Java……最小公倍数---大数表示)
- 【POJ 3101】Astronomy(GCD+LCM+公式)
- POJ 3101 Astronomy 轨道相遇问题,求n个分数的最小公倍数
- POJ 3101 Astronomy (挖坑待学Java……最小公倍数---大数表示)
- poj 3101 Astronomy
- (Relax 数论 1.17)POJ 3101 Astronomy(分数的最小公倍数)
- POJ 3101 Astronomy 可能会
- POJ 3101 Astronomy
- POJ - 3101 Astronomy(有理数的公倍数)
- POJ 3101 Astronomy 解题报告(大数乘法+分数最小公倍数)
- POJ 3101 Astronomy 笔记
- POJ 3101 Astronomy
- poj 3101 Astronomy(分数的最小公倍数)