using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int cardCount = int.Parse(Reader.ReadLine()); int[] cardA = Reader.GetInt(); int[] cardB = Reader.GetInt(); List> listA = this.getKumiawase(new List(cardA)); List> listB = this.getKumiawase(new List(cardB)); int aWin = 0; int bWin = 0; int even = 0; listA.ForEach((a)=>{ listB.ForEach((b)=>{ int cntA = 0; int cntB = 0; for(int i=0; i b[i]) { cntA++; } else if(a[i] < b[i]) { cntB++; } } if(cntA > cntB) { aWin++; } else if(cntB > cntA) { bWin++; } else { even++; } }); }); double ans = aWin / (double)(bWin+even+aWin); Console.WriteLine(ans); } private List> getKumiawase(List target) { List> ans = new List>(); if(target.Count == 0) { ans.Add(new List()); ans[0].AddRange(target); return ans; } for(int i=0; i subTarget = new List(target); subTarget.RemoveAt(i); List> tmp = this.getKumiawase(subTarget); foreach (List ansItem in tmp) { List item = new List(ansItem); item.Insert(0, target[i]); ans.Add(item); } } return ans; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 3 6 2 3 1 5 4 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }