package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) n := nextInt() a, b := make([]int, n), make([]int, n) for i := range a { a[i] = nextInt() } for i := range b { b[i] = nextInt() } win, all := 0, 0 f := func(a []int) { c := 0 for i, v := range a { if v > b[i] { c++ continue } if b[i] > v { c-- continue } } if c > 0 { win++ } all++ } perm(a, n, f) fmt.Println(float64(win) / float64(all)) } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i } func comb(a []int, r int, fn func([]int)) { if r > len(a) || r < 1 { return } var f func([]int, int, int) f = func(ret []int, last, c int) { if c == 0 { fn(ret) return } c-- for i, v := range a[last : len(a)-c] { ret[r-c-1] = v f(ret, i+last+1, c) } } ret := make([]int, r) f(ret, 0, r) } func perm(a []int, r int, fn func([]int)) { permL := make([]int, r) f := func(s []int) { copy(permL, s) k, i := 1, 0 c := make([]int, r+1) for i := 1; i < len(c); i++ { c[i] = i } for k < r { if k&1 == 1 { i = c[k] } else { i = 0 } permL[k], permL[i] = permL[i], permL[k] fn(permL) k = 1 for ; c[k] == 0; k++ { c[k] = k } c[k]-- } } if r < 2 { comb(a, r, fn) return } comb(a, r, f) }