#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; constexpr long long int INFLL = 1LL << 60; constexpr int INF = 1000000007; const double INFD = 1e100; const int mod = 1000000007; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int N; double p[2]; int cards[2][20]; double rec[2][20][20]; double dp[(1<<20)]; void solve(int t){ fill(dp, dp+(1<=0; bit--){ bool fst=true; for(int i=0; i> i & 1){ int nbit = bit ^ (1 << i); int cnt = __builtin_popcount(bit); int step = N-cnt; if(cnt==1){ rec[t][i][step] += dp[bit]; dp[nbit] += dp[bit]; }else{ double prob = (fst ? p[t] : (1-p[t])/(cnt-1)); rec[t][i][step] += dp[bit] * prob; dp[nbit] += dp[bit] * prob; fst = false; } } } } } int main(){ cin >> N >> p[0] >> p[1]; for(int i=0; i> cards[0][i]; } for(int i=0; i> cards[1][i]; } sort(cards[0],cards[0]+N); sort(cards[1],cards[1]+N); solve(0); solve(1); double ans=0.0; for(int step=0; step