package common;
/**
* @author : zhaoliang
* @program :newCoder
* @description : 变态跳台阶
* @create : 2020/11/21 14:28
*/
public class JumpFloorII {
//可以跳上一级,也可以跳上n级
//假设n>=2,第一步有n种跳法,f(n) = f(n-1)+f(n-2)+...f(1) =>f(n) = 2f(n-1)
public static int jumpFloorII(int n){
return 1 << --n;//2^(n-1) 用位移操作进行,更快
}
//补充,java中
//"<<"左移运算符,等同于乘2的n次方
//">>"右移运算符,等同除2的n次方
//">>>" 无符号右移,右移左侧以0填充
}