动态规划方法

    1. int numWays(int n){
    2. if (n == 0) return 1;
    3. if (n == 1) return 1;
    4. if (n == 2) return 2;
    5. unsigned long long t1 = 2, t2 = 1, result = 0;
    6. for (int i = 3;i <= n;++i) {
    7. result = (t1 + t2)%1000000007;
    8. t2 = t1;
    9. t1 = result;
    10. }
    11. if (result == 1000000008) return 1;
    12. return result;
    13. }