题目如下:
Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20×20 grid?
这属于经典的排列组合题目,常在小学奥数上出现,一般有两种做法,动态规划和组合,从左上角到右下角一共需要经过4段,2个横,2个纵,总的路径条数为
那么20*20的格子同样,代码如下
format longG
nchoosek(20+20,20)