#C3925. Unique Paths in a Square Grid
Unique Paths in a Square Grid
Unique Paths in a Square Grid
You are given a positive integer n
representing the dimensions of a square grid. Your task is to compute the number of unique paths from the top-left corner to the bottom-right corner when you are only allowed to move either to the right or down.
The number of unique paths in an n × n
grid is given by the formula:
If the input is not a positive integer, the result should be 0
.
Note: The input is read from stdin
and the output must be printed to stdout
.
inputFormat
A single line containing a value which should represent a positive integer n
. If the value cannot be parsed as a positive integer, then output should be 0.
outputFormat
A single line containing the number of unique paths from the top-left corner to the bottom-right corner of an n × n
grid (using only right and down moves). Output 0 for invalid input.## sample
1
1