#K13396. Unique Paths in a Grid
Unique Paths in a Grid
Unique Paths in a Grid
You are given a grid with M rows and N columns. Starting from the upper-left corner, your task is to find the number of unique paths to reach the bottom-right corner of the grid. You are only allowed to move either right or down.
The answer can be computed using dynamic programming. Note that the result should be given modulo \(10^9+7\).
For reference, the number of unique paths is given by the formula:
\[ \binom{M+N-2}{M-1} \]
Make sure your solution reads from the standard input and writes to the standard output.
inputFormat
The input consists of a single line containing two space-separated integers M and N, where M is the number of rows and N is the number of columns of the grid.
outputFormat
Output a single integer representing the number of unique paths from the top-left corner to the bottom-right corner of the grid modulo (10^9+7).## sample
2 3
3