class Calc0133 EPS = 1e-2 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @n = args.shift.first.to_i @as = args.shift.map(&:to_i) @bs = args.shift.map(&:to_i) end def run @as.permutation.map { |as| @bs.permutation.count { |bs| as.zip(bs).count { |a, b| a > b } > @n / 2 } }.inject(:+).to_f / (1..@n).inject(:*) ** 2 end end puts Calc0133.new(STDIN.readlines).run if __FILE__ == $0