递推
21情况有1种
22情况有3种
f[i]=f[i-1]+2f[i-2] (有种情况重复,这是从大的方格来看,如果从小的21,12方格来看,多了一列,竖着放1种情况,2个横着1种情况,2*2的一种情况)
#include<stdio.h>
#include<iostream>
#include<algorithm>
#define MAXN_ROW 100
#define MAXN_COL 100
using namespace std;
int t;
int N;
int a[31];
int main()
{
scanf("%d", &t);
a[1] = 1;
a[2] = 3;
for (int i = 3; i <= 30; i++)
{
a[i] = a[i - 1] + 2*a[i - 2];
}
while (t--)
{
scanf("%d", &N);
printf("%d\n", a[N]);
}
return 0;
}