I would like to know how to comprehend a Overflow error. This month long challenge had a question Floori4 ,I was not able to do that question partially due to overflow errors and understanding of modular arithmatic. Example : link text My this solution gave WA. While my link text solution gave AC .If you notice the difference is in brackets in ans=(ans*((3nn+3*n+M-1)%M))%M so how can I comprehend it.
And can you please give some pointers on how to deal with it in future.