#t315. 移动路线
移动路线
Number of Paths
Problem Background
Special for beginners, ^_^
Problem Description
On table X there is an -row, -column grid matrix. Each cell is represented by coordinates: the row coordinate increases from bottom to top, and the column coordinate increases from left to right. The bottom-left cell has coordinates , so the top-right cell has coordinates .
Xiaoming, a naughty child, once caught an ant and accidentally injured its right foot, so the ant can only move up or to the right. Xiaoming places the ant in the bottom-left cell, and it moves from the bottom-left cell to the top-right cell, one cell per step. The ant always stays within the grid. Count the number of different paths.
For a grid, the ant does not move, so the number of paths is 1.
For a (or ) grid, the ant only needs one move to the right (or up), so the number of paths is also 1.
...
For a grid, as shown below:
(2,1) (2,2) (2,3)
(1,1) (1,2) (1,3)
The ant has 3 paths:
Path 1: (1,1) → (1,2) → (1,3) → (2,3)
Path 2: (1,1) → (1,2) → (2,2) → (2,3)
Path 3: (1,1) → (2,1) → (2,2) → (2,3)
Input Format
One line containing two integers and , representing the number of rows and columns of the grid, separated by a space.
Output Format
One line containing the number of different paths.
Sample Input
2 3
Sample Output
3
Constraints
1 second, 1024 KiB for each test case.