#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; unsigned xor128(){ static unsigned x=123456789,y=362436069,z=521288629,w=88675123; unsigned t; t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) ); } int main() { int n; double pa, pb; cin >> n >> pa >> pb; vector a(n), b(n); for(int i=0; i> a[i]; for(int i=0; i> b[i]; const int LOOP_TIME = 500000; int win = 0; for(int t=0; t x = a; vector y = b; int score = 0; for(int i=0; i pa){ int j = xor128() % (n - 1 - i) + 1; swap(x[0], x[j]); } if(xor128() / (double)UINT_MAX > pb){ int j = xor128() % (n - 1 - i) + 1; swap(y[0], y[j]); } } if(x[0] > y[0]) score += x[0] + y[0]; else if(x[0] < y[0]) score -= x[0] + y[0]; swap(x[0], x[n-1-i]); swap(y[0], y[n-1-i]); } if(score > 0) ++ win; } double ans = win / (double)LOOP_TIME; printf("%.10f\n", ans); return 0; }