# 跳台阶以及变态跳台阶问题

public class Solution {
public int JumpFloor(int target) {

if(target==0){
return 0;
}else if(target==1){
return 1;
}else if(target==2){
return 2;
}else{
return JumpFloor(target-2)+JumpFloor(target-1);
}
}

public static void main(String [] args){
Solution s = new Solution();
System.out.println(s.JumpFloor(4));
}
}

public class Solution {
public int JumpFloor(int target) {
if(target==1||target==2){
return target;
}else{
int pre=1;
int cur=1;
for(int i=0;i<target-1;i++){
int temp;
temp=cur;
cur=pre+cur;
pre=temp;
}
return cur;//如果i<target的话，就return pre;
}
}

public static void main(String [] args){
Solution s = new Solution();
System.out.println(s.JumpFloor(4));
}
}

public class Solution {
public int JumpFloorII(int target) {
if(target==0){
return 0;
}else if(target==1){
return 1;
}else if(target==2){
return 2;
}else{
return 2*JumpFloorII(target-1);
}
}

public static void main(String [] args){
Solution s = new Solution();
System.out.println(s.JumpFloorII(4));
}
}

f(0)=0;
f(1)=1;
f(2)=f(2-1)+f(2-2);//当还剩下两阶时，紧接着还可以在跳一阶，两阶
f(3)=f(3-1)+f(3-2)+f(3-3);//当还剩下三阶时，紧接着还可以在跳一阶，两阶，三阶
....
....
f(n-1)=f(n-2)+f(n-3)+f(n-4)+...+f(n-1-(n-2))+f(n-1-(n-1));//当还剩下n-1阶时，紧接着还可以在跳一阶，两阶，三阶，...，n-2阶，n-1阶
f(n)=f(n-1)+f(n-2)+f(n-3)+f(n-4+...+f(n-(n-1))+f(n-n);