class Integer def factorial (1..self).inject(1){|r, i| r * i} end def combination(n) self.factorial / (n.factorial * (self - n).factorial) end end def pepsi(m, n) result = (0..m).inject(0){|r, i| r + (-1)**i * m.combination(i) * (m - i)**n} (result * 10000000000000000 / m**n).to_f / 10000000000000000 end puts pepsi(ARGV[0].to_i, ARGV[1].to_i)