CNTWAYS - Editorial

@betlista you are saying that (0,0)->(p,b-1)->(p,b)->(n,m) will occurs twice in the case of (p,b-1) and again for (p,b).But this will happen with (p,b-1) also.It will also occurs twice one for (p,b-2) and for (p,b-1) in this way again we are over counting. Am i right??

nice tutorial!!!
http://www.bmlc.ca/PureMath30/Pure%20Math%2030%20-%20Combinatorics%20Lesson%203.pdf

1 Like

because the range of N+M is upto 800000 …
and n+m are the number of steps which ant has to move
correct me if i m wrong…

I m getting TLE by this approach…
can ny1 check my code http://www.codechef.com/viewsolution/2842354

I didn’t know that there was another method other than power and extended euclidean for finding modular inverse. Thank you.

Is this possible that MOD is not a prime number ? then how can we solve this?

@fushar can you please tell me whats wrong with my code. Its completely based on your editorial. Please can someone help me?
http://www.codechef.com/viewsolution/5970315

Can somebody pls explain to me in detail why we need to first go from 0,0 to p,b-1 and not directly to p,b
i did not get the explanation given fr this.