- f(1) = 1
- f(2) = 1 + 1 = 2
- f(3) = 1 + 2 + 1 = 4
- f(4) = 1 + 2 + 4 + 1 = 8
所以 f(n) = 2 n − 1 ^{n-1} n−1
import java.util.Scanner;
public class Solution {
public int jumpFloorII(int target) {
return 1 << (target - 1);
}
}
所以 f(n) = 2 n − 1 ^{n-1} n−1
import java.util.Scanner;
public class Solution {
public int jumpFloorII(int target) {
return 1 << (target - 1);
}
}