#P2265. Counting Water Flows in a Grid
Counting Water Flows in a Grid
Counting Water Flows in a Grid
Given the length L and the width W of a water channel grid, count the number of water flows that consist solely of left and upward moves from the bottom-right corner to the top-left corner. In other words, you need to compute the number of distinct paths from the bottom-right corner to the top-left corner if at each step you can only move left or up.
The answer can be computed using the binomial coefficient:
\[ \text{Answer} = \binom{L+W-2}{L-1} \]
Note: You can assume that L and W are positive integers greater than or equal to 2.
inputFormat
The input consists of two space-separated integers: L and W, representing the length and width of the grid, respectively.
outputFormat
Output a single integer, which is the number of distinct water flows that only use left and upward moves.
sample
2 2
2