LeetCode - Climbing Stairs

n = 1*a + 2*b;  find ways.

if(a==n)  b=0;  way0 = C(n-0,0) = 1;

if(a==n-2)  b=1;  way1 = C(n-1,1);

if(a==n-4)  b=2;   way2 = C(n-2,2);

...

if(a==n-2*i)  b=i;   wayi = C(n-i,i);

 

as, i = 0,1,..., [n/2]


Fibonacci Sequence http://zh.wikipedia.org/wiki/%E6%96%90%E6%B3%A2%E9%82%A3%E5%A5%91%E6%95%B0%E5%88%97#.E5.92.8C.E9.BB.83.E9.87.91.E5.88.86.E5.89.B2.E7.9A.84.E9.97.9C.E4.BF.82

 

posted on 2013-04-16 21:28  highstar88  阅读(130)  评论(0编辑  收藏  举报

导航