We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The solution has little to do with elementary facts about combinatorials, and a lot to do with properties of modular arithmetic where the modulus is a prime number. 1000000007 happens to be a prime number.
I copied the solution provided by shell87301, below, only translating it to Python3. It was both gratifying and humiliating to see it work after so many tries on my own.
Matrix Tracing
You are viewing a single comment's thread. Return to all comments →
The solution has little to do with elementary facts about combinatorials, and a lot to do with properties of modular arithmetic where the modulus is a prime number. 1000000007 happens to be a prime number. I copied the solution provided by shell87301, below, only translating it to Python3. It was both gratifying and humiliating to see it work after so many tries on my own.