有一個小行星被預測會撞上地球,科學家想利用月球擋住小行星,但需要讓月球在小行星到達時剛好在地球與小行星中間,所以我們需要增加或減少月球的重量,減少一噸會讓月球繞地球的速度增加 1mm/1,增加一噸則減少,並且我們可以得到
T: 小行星還有幾天會到
S: 月球繞地球現在的速度
D: 月球在小行星到達時距離撞擊點多遠
我們需要找出要讓月球重量變化多少才能讓地球逃過一劫
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
double T, S, D;
cin >> T >> S >> D;
double mass = (D * 1000 * 1000) / (T * 24 * 60 * 60);
if (floor(mass) > 0) {
cout << "Remove " << floor(mass) << " tons" << endl;
} else {
cout << "Add " << floor(abs(mass)) << " tons" << endl;
}
}
return 0;
}