HDU 2190 悼念512汶川大地震遇难同胞——重建希望小学

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2190

递推,找规律不难.

#include <iostream>

using namespace std;

int main()
{
    int T;
     __int64 d[31] = {0, 1, 3, 5};

    for (int i = 4; i < 31; i++)
        d[i] = d[i-1] + 2*d[i-2];
    cin>>T;
    for(int i=0;i<T;i++)
    {
        int n;
        cin>>n;
        cout<<d[n]<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/destino74/p/3332034.html