#include using namespace std; double solve(int N, double p, double q){ if (p == 1){ return 1; }else if (p == 0){ return 0; }else if (q == 1){ return 0; }else if (q == 0){ return p; } vector f(N + 2, 0.0); vector b(N + 2, 0.0); vector new_f(N + 2, 0.0); vector new_b(N + 2, 0.0); f[1] = 1.0; double precision = 0.0005; double dead = 0; double returned = 0; double finished = 0; double alive = 1.0; double r = 1.0 - p - q; while (alive > returned * precision){ new_f.assign(N + 2, 0.0); new_b.assign(N + 2, 0.0); for (int i = 1; i <= N; ++i){ new_b[i - 1] += p * f[i] + q * b[i]; new_f[i + 1] += q * f[i] + p * b[i]; dead += r * f[i] + r * b[i]; } returned += new_b[0]; finished += new_f[N + 1]; alive = 1.0 - dead - returned - finished; swap(f, new_f); swap(b, new_b); } return returned; } int main() { ios::sync_with_stdio(false); cout.tie(0); int N; double p, q; cin >> N >> p >> q; cout << fixed << setprecision(15) << solve(N, p, q) << endl; return 0; }