此题与斐波拉契思路一模一样,DP,再采用状态压缩
1 class Solution { 2 public: 3 int jumpFloor(int number) { 4 if(number==1)return 1; 5 if(number==2)return 2; 6 int l1=1,l2=2; 7 for(int i=3;i<=number;++i){ 8 int temp=l1+l2; 9 l1=l2; 10 l2=temp; 11 } 12 return l2; 13 } 14 };