#include using namespace std; using ll = long long; #define rep(i, n) for(int i = 0; i < (n); i++) #define pb push_back const int maxn = 10000; const int INF32 = 1'050'000'000; const long long INF64 = 4'000'000'000'000'000'000; const int MOD7 = 1'000'000'007; const int MOD9 = 1'000'000'009; void ERROR(int num) { printf("ERROR%d!\n",num); } ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } int dx[8]={-1,0,1,0,1,1,-1,-1}; int dy[8]={0,-1,0,1,1,-1,1,-1}; int N; vector A, B; vector> PERM1, PERM2; int CMP(int a, int b){ int cntA = 0, cntB = 0; rep(i,N){ int numA = PERM1[a][i]; int numB = PERM2[b][i]; if(numA > numB) cntA++; else cntB++; } return (cntA > cntB) ? 1:0; } void PRINT(vector P, int num){ cout << "SHOW" << num << ": "; rep(i,P.size()){ cout << P[i] << " "; } cout << endl; } int main(){ cin >> N; A.resize(N); B.resize(N); rep(i,N) cin >> A[i]; rep(i,N) cin >> B[i]; sort(A.begin(),A.end()); sort(B.begin(),B.end()); do{ PERM1.pb(A); //PRINT(A,1); }while(next_permutation(A.begin(),A.end())); do{ PERM2.pb(B); //PRINT(B,2); }while(next_permutation(B.begin(),B.end())); int cnt = 0; rep(a,PERM1.size()){ rep(b,PERM2.size()){ cnt += CMP(a,b); } } double P = (double)(cnt) / ((double)(PERM1.size()) * (double)(PERM2.size())); cout << P << endl; }