HDU 2046 骨牌铺方格

线性Dp Fabonacci

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

long long n, dp[55];

int main()
{
    while (~scanf("%d", &n))
    {
        memset(dp, 0, sizeof(dp));
        dp[1] = 1, dp[2] = 2;
        for (int i = 3; i <= n; ++i)
            dp[i] = dp[i - 1] + dp[i - 2]; 
        printf("%lld\n", dp[n]);
    }
    return 0;
}

 

posted @ 2018-12-13 09:17  Christopher_Yan  阅读(95)  评论(0编辑  收藏  举报