#![allow(unused_imports)] #![allow(non_snake_case)] use std::collections::HashMap; use std::collections::HashSet; #[allow(unused_macros)] macro_rules! read { ([$t:ty] ; $n:expr) => ((0..$n).map(|_| read!([$t])).collect::>()); ($($t:ty),+ ; $n:expr) => ((0..$n).map(|_| read!($($t),+)).collect::>()); ([$t:ty]) => (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::>()); ($t:ty) => (rl().parse::<$t>().unwrap()); ($($t:ty),*) => {{ let buf = rl(); let mut w = buf.split_whitespace(); ($(w.next().unwrap().parse::<$t>().unwrap()),*) }}; } #[allow(dead_code)] fn rl() -> String { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); buf.trim_end().to_owned() } trait IteratorExt: Iterator + Sized { fn vec(self) -> Vec { self.collect() } } impl IteratorExt for T {} fn main() { let n = read!(usize); let a = read!([isize]); let b = read!([isize]); println!("{}", help(make_table(a, b), n).iter().filter(|&&e| e > 0).count() as f64 / fact(n) as f64); } fn fact(n: usize) -> usize { let mut tmp = 1; for i in 2..=n { tmp *= i; } tmp } fn c(a: isize, b: isize) -> isize { if a > b { 1 } else { -1 } } fn make_table(a: Vec, b: Vec) -> Vec> { let mut v = vec![]; for eb in b.iter() { let mut row = vec![]; for ea in a.iter() { row.push(c(*ea, *eb)); } v.push(row); } v } fn help(table: Vec>, size: usize) -> Vec { if size == 1 { return vec![table[0][0]]; } let mut v = vec![]; for i in 0..=size-1 { let mut arg_v = table.clone(); arg_v.remove(0); for row in arg_v.iter_mut() { row.remove(i); } for e in help(arg_v, size-1).iter() { v.push(e + table[0][i]); } } v }