首页 > 代码库 > hdoj:2045

hdoj:2045

#include <iostream>
using namespace std;
long long a[51];

int main()
{
    int n;
    a[1] = 3;
    a[2] = 6;
    a[3] = 6;
    for (int i = 4; i <= 50; i++)
    {
        a[i] = a[i - 1] + 2 * a[i - 2];
    }
    while (cin >> n)
    {
        cout << a[n] << endl;
    }
}

 

hdoj:2045