题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2606
题意: 用1*1,2*2,3*3,4*4的正方形填充4*n的矩形, 问有多少种不同填法。
分析: f[i] = f[i - 1] + f[i - 2] * 4 + f[i - 3] * 2 + f[i - 4] * 1 + 对错位的情况(即2*(f[n-3] + f[n-4] + ...f[0]), f[0]初始化为1)
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#define LL long long
#define mod 19890907
#define inf 0x3f3f3f3f
#define N 10010
using namespace std;
int f[];
void init()
{
f[]=;f[]=;f[]=;f[]=;
for(int i=;i<=;i++)
{
f[i]=(f[i-]+f[i-]*+f[i-]*+f[i-])%mod;
for(int j=;j<=i;j++)f[i]=(f[i]+*f[i-j])%mod;
}
}
int main()
{
int n,t;
init();
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
printf("%d\n",f[n]);
}
}