public class Solution {
//f(1) = 1 f(2) = 2 f{3) = 3
//
public int jumpFloor(int target) {
return f(target);
}
public int f(int n){
//公式 f(n) = f(n-1)+f(n-2)
if(n <= 0){
return 0;
}
if(n == 1){
return 1;
}
if(n == 2){
return 2;
}
int result = 0;
int a = 1; //f(n-2)
int b = 2; //f(n-1)
for(int i = 3;i<=n;i++){
result = a + b;
a = b;
b = result;
}
return result;
}
}