#T171. 移动路线
移动路线
Description
There is a grid matrix with m rows and n columns on table X. Each grid can be represented by coordinates, where the row coordinates increase from bottom to top, and the column coordinates increase from left to right. The bottom-left grid has coordinates (1,1), and the top-right grid has coordinates (m,n).
Xiao Ming is a mischievous child. One day, he caught an ant and accidentally injured its right foot, so the ant can only move upward or to the right. Xiao Ming placed the ant in the bottom-left grid, and the ant moves from the bottom-left grid to the top-right grid, moving one grid per step. The ant always moves within the grid matrix. Please calculate the number of distinct movement paths.
For a 1-row × 1-column grid matrix, the ant moves in place, and the number of paths is 1. For a 1-row × 2-column (or 2-row × 1-column) grid matrix, the ant only needs to move right (or upward) once, and the number of paths is also 1... For a 2-row × 3-column grid matrix, as shown in the following figure:
(2,1) (2,2) (2,3)
(1,1) (1,2) (1,3)
Ants have a total of 3 possible movement paths:
(Note: The original Chinese text appears to be an incomplete statement. The English translation maintains the same structure while being grammatically correct. If this is part of a larger context, please provide the full text for a more accurate translation.)
路线1:(1,1) → (1,2) → (1,3) → (2,3)
路线2:(1,1) → (1,2) → (2,2) → (2,3)
路线3:(1,1) → (2,1) → (2,2) → (2,3)
Input Format
The input consists of a single line containing two integers, m and n (0 < m + n ≤ 20), representing the number of rows and columns of the grid matrix, respectively. The integers m and n are separated by a space.
Output Format
The output consists of a single line, which is the number of distinct movement paths.
2 3
3