标签:.com class == long png while 楼梯 bst 爬楼梯
代码:
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 ;
    }
};
截图:
标签:.com class == long png while 楼梯 bst 爬楼梯
原文地址:http://www.cnblogs.com/w1500802028/p/7296440.html