#include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n; double p, q; cin >> n >> p >> q; vector p0(n+1), p1(n+1); vector p0_pre(n+1), p1_pre(n+1); p0[1] = 1; auto ok = [&](){ auto p = accumulate(p0.begin(), p0.end(), 0.0)+accumulate(p1.begin(), p1.end(), 0.0); // cout << p << endl; return p < 0.0009; }; double ans = 0.0; while(!ok()){ swap(p0, p0_pre); swap(p1, p1_pre); p0[0] = 0; p0[n] = 0; p1[0] = 0; p1[n] = 0; ans += p0_pre[1]*p+p1_pre[1]*q; for(int i = 1; i <= n-1; i++){ p0[i] = p0_pre[i-1]*q+p1_pre[i-1]*p; p1[i] = p0_pre[i+1]*p+p1_pre[i+1]*q; } } cout << ans << endl; }