1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-4;
double W0, W, M;
bool check(double x) { double sum = 0, p = 1; for (double i = 1; i <= M; ++i) { p *= (1 + x); sum += W / p; } return sum <= W0; }
int main() { ios::sync_with_stdio(false); cin >> W0 >> W >> M; double l = 0, r = 5; while (r - l > eps) { double mid = (l + r) / 2; if (check(mid)) r = mid; else l = mid; } printf("%.1lf", l * 100); return 0; }
|