12×12 网格路径数
Walking on a Grid
题目详情
从 方格的左下角走到右上角,每一步只能向右或向上。问共有多少条不同路径?
You start at the bottom-left corner of a grid and want to reach the top-right corner. At each step, you can either move right or move up. How many distinct paths can you take to reach the top-right corner?
解析
一共需要走 24 步,其中向右 12 步、向上 12 步。
不同路径数等于在 24 个位置中选出 12 个位置放“向上”的方式数:
Original Explanation
To move from the bottom-left to the top-right corner of a grid, you must make exactly 12 right moves (R) and 12 up moves (U), for a total of 24 moves. The problem becomes: In how many ways can you arrange a sequence with 12 R's and 12 U's?
This is a classic combinations problem. The number of such sequences is given by the number of ways to choose 12 positions for U (or R) out of 24 total moves:
Computing this gives:
So, there are 2,704,156 distinct paths from the bottom-left to the top-right corner.