编程介的小学生 2019-06-25 16:47 采纳率: 20.5%
浏览 94

计算三个天体什么时候对齐的一个算法的问题,怎么采用C语言的程序的设计的编写的过程的方法来计算怎么做的

Problem Description
The Astrologically Clairvoyant Manufacturers have always used the celestial skies to make more accurate forecasts. Most of their predictions are based on a Star-Planet-Satellite alignment. There are some scientific reasons for this, mostly tidal changes: the gravitational pull of these celestial bodies will pull the water towards them. The greatest tides occur when the Sun, Earth, and Moon are perfectly aligned.

Always willing to expand its share of the market, the ACM has decided to generalize its predicitions to other planetary systems. However, on those systems the celestial bodies move at different speeds than in ours, so the predictions which depend on the Star-Planet-Satellite alignment must be recalculated. Can you help them automate some of their computations?

For some stellar system, at some point of the future denoted as t = 0, the star, a planet and a moon of the planet will be aligned on the galactic x axis. The star will be at position (0, 0), the planet will be at position (p, 0), and its planet will be at position (m, 0). The planet moves around the star in a perfect circle, on the galactic xy plane, and completes a revolution in u Earth days. Similarly, the moon revolves around the planet in v Earth days, in a perfect circle and on the same galactic plane. In other words, at t = u the planet will be back at position (p, 0), and at t = v the moon will once again have the same y coordinate as the planet and will be on the same side of the planet as when t was zero.

When will the three celestial bodies be aligned again?

Input
The first line of input will contain a non-negative integer n, which represent the number of test cases. For each test case, you will be given one line containing the non-zero integers u and v, all of which could be negative. The distance between the moon and the planet will be strictly smaller than distance between the planet and the star, and the revolution durations won’t cause the celestial bodies to be permanently aligned. A positive revolution duration indicates that a celestial body revolves counter-clockwise, and a negative revolution duration indicates clockwise motion.

Output
For each test case, find the minimum positive number t such that after that number of Earth days, the three celestial bodies will be perfectly aligned again. Output that number with three decimal places, rounding to the nearest allowed value.
The magnitude of the numbers in the input will be at most 1000.

Sample Input
2
1 -1
2 1

Sample Output
0.250
1.000

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog