#K44347. Unique Paths in a Grid
Unique Paths in a Grid
Unique Paths in a Grid
Given an \(m \times n\) grid, your task is to compute the number of unique paths from the top-left corner to the bottom-right corner, moving only right or down. The number of unique paths can be derived using the combinatorial formula:
\[ \binom{m+n-2}{m-1} = \frac{(m+n-2)!}{(m-1)! (n-1)!} \]
Make sure your program reads input from stdin
and writes output to stdout
.
inputFormat
The input consists of two positive integers m and n (separated by space) which denote the number of rows and columns of the grid respectively.
outputFormat
Output a single integer representing the number of unique paths from the top-left corner to the bottom-right corner of the grid.
## sample3 7
28