網格路線問題

問題:

Starting in thetop left corner of a 2×2 grid, and only being able to move to the right anddown, there are exactly 6 routes to the bottom right corner.

wKioL1QY14uRSMSNAABNuYllRXw766.jpg

How many suchroutes are there through a 20×20 grid?

解決思路:

 wKiom1QY13OSdoOHAAFhuJDy8PM676.jpg

wKioL1QY14vjdiN9AAE9dC36KA4647.jpg

wKiom1QY13PyjsOyAAF9NvpmhhY213.jpg

 

將上圖數據放正,就是楊輝三角:

前十行如下:










1


















1


1
















1


2


1














1


3


3


1












1


4


6


4


1










1


5


10


10


5


1








1


6


15


20


15


6


1






1


7


21


35


35


21


7


1




1


8


28


56


70


56


28


8


1


1


9


36


84


126


126


84


36


9


1

 

11 行:

1104512021025221012045101

12 行:

1115516533046246233016555111

13行:

1126622049579292479249522066121

14行:

11378286715128717161716128771528678131

……

n-1行:

1,(n-1C1,(n-2C2,(n-1Cr-1),,(n-1Cn-2),1

n行:

1nC1nC2nCr-1),nCrnCr-1),1

 

問題要求的20*20的網格的路徑數目,即楊輝三角第41行第21個數。

利用楊輝三角的性質:

n行的m個數可表示爲C(n-1,m-1),即爲從n-1個不同元素中取m-1個元素的組合數。

組合數計算方法:C(n,m)=n!/[m!(n-m)!]

可計算第41行,第21個數爲:C(40,20)=40!/[20!*20!]=137846528820


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章