思路:
经过一系列公式的每次到达最高点时s = E / mg,还有下坠所以每隔一次落地有两次要乘以2得 s = 2E / m*g。
代码:
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define debug(a) cout << "debug : " << (#a) << " = " << a << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 998244353;
int main()
{
double ans = 0, p, E = 1000, m, g = 9.8;
cin >> m >> p;
while (E > eps)
{
ans += (200 * E) / (m * g);
E -= E * (p / 100);
}
printf("%.3lf", ans);
return 0;
}