编程介的小学生 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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 易语言把MYSQL数据库中的数据添加至组合框
    • ¥20 求数据集和代码#有偿答复
    • ¥15 关于下拉菜单选项关联的问题
    • ¥20 java-OJ-健康体检
    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况