#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_DEPRECATE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair Pii; typedef pair Pll; #define FOR(i,n) for(int i = 0; i < (n); i++) #define sz(c) ((int)(c).size()) #define ten(x) ((int)1e##x) #define tenll(x) ((ll)1e##x) // #pragma comment(linker,"/STACK:36777216") template void chmax(T& l, const T r) { l = max(l, r); } template void chmin(T& l, const T r) { l = min(l, r); } void shu(int* a, int n, double p) { vector cur(a, a + n); FOR(i, n) { int x = rand(); if (x / double(RAND_MAX) <= p) { a[i] = cur.back(); cur.pop_back(); } else { int idx = rand() % (n - i); a[i] = cur[idx]; cur.erase(cur.begin() + idx); } } } int main() { int n; double pa, pb; cin >> n >> pa >> pb; int a[20], b[20]; FOR(i, n) cin >> a[i]; FOR(i, n) cin >> b[i]; sort(a, a + n); sort(b, b + n); reverse(a, a + n); reverse(b, b + n); srand(time(NULL)); const int X = ten(5) * 4; int ans = 0; int _a[20] = {}, _b[20] = {}; FOR(_, X) { memcpy(_a, &a[0], sizeof(a)); memcpy(_b, &b[0], sizeof(b)); shu(_a, n, pa); shu(_b, n, pb); int da = 0; FOR(i, n) { int sm = _a[i] + _b[i]; if (_a[i] > _b[i]) da += sm; else da -= sm; } if (da > 0) ans++; } printf("%.10lf\n",ans / double(X)); }