Help needed to understand problem 559C

Revision en1, by akash_goel, 2015-07-24 20:24:01

Here is the link — http://codeforces.me/problemset/problem/559/C This is similar to this — https://www.codechef.com/CDCRF15R/problems/CWAYS/

In the solutions, I can see inverse factorial being calculated as

inv(n) = pow(n,mod-2)

I don't get where the mod-2 value comes from. Can someone please explain?

Tags combinatorics, dp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English akash_goel 2015-07-24 20:24:01 378 Initial revision (published)