• + 0 comments

    Can anyone tell me why this times out on the last 6 test cases? It's in Ruby. I'm not sure how to make it quicker.

    tot, mod = 1, 10**9+7
    (1..[m,n].min).each do |j|
        tot *= j**(1+(m-n).abs + 2*([m,n].min-j)) % mod
        tot %= mod end
    puts tot % mod