爬楼梯
2017-03-09 15:10 1500802028 阅读(105) 评论(0) 编辑 收藏 举报
class Solution {
public:
/**
* @param n: An integer
* @return: An integer
*/
int climbStairs(int n) {
// write your code here
if(n==0)
return 1;
long s = 1;
int i=1;
int j=n-i;
while(i<=j){
s=s+(getCni(j,i)+0.1);
i++;
j=n-i;
}
return s;
}
long getCni( long n, long i){
long s = 1;
for (int j = 0; j<i; j++ ){
s = s*( n - j )/(j+1);
}
return s ;
}
};