题目描述:
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
某一级要么是从它下一级的爬上来的,要么是从它的下两级爬上来的。
class Solution {
public:
int climbStairs(int n)
{
int v[n+1];
v[0]=1;
v[1]=1;
for(int i=2;i<=n;i++)
{
v[i]=v[i-1]+v[i-2];
}
return v[n];
}
};
6084



被折叠的 条评论
为什么被折叠?



