How much... in 3D! Build blocks dp, 12446133 ..
Question link: Click the open link
Question:
The number of squares of 2*2 * N is calculated using the square of 1*1*2.
There are nine statuses for each layer.
0. All values are 1.
1,
00
__
0 indicates that this is null, __indicates that the two are lying on one square
2,
00
11
0 indicates that this is null, and 1 indicates that the square block is standing upright.
In this way, there are 8 states except 0th, and then simple transfer.
Other statuses are invalid and will not be involved in the calculation of answers, so you do not need to consider
#include <string>#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#include <queue>#include <set>#include <map>#include <vector>template <class T>inline bool rd(T &ret) {char c; int sgn;if(c=getchar(),c==EOF) return 0;while(c!='-'&&(c<'0'||c>'9')) c=getchar();sgn=(c=='-')?-1:1;ret=(c=='-')?0:(c-'0');while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');ret*=sgn;return 1;}template <class T>inline void pt(T x) { if (x <0) { putchar('-'); x = -x; } if(x>9) pt(x/10); putchar(x%10+'0');}using namespace std;const int N = 1000100;const int mod = 1000*1000*1000+7;void add(const int &y,int& x){x += y;if(x >= mod) x-=mod;}int d[N][9];int main() {memset(d, 0, sizeof d);d[0][0] = 1;for(int i = 0; i < N-1; i++){add(d[i][1], d[i][0]);add(d[i][2], d[i][0]);add(d[i][4], d[i][0]);add(d[i][5], d[i][0]);add(d[i][6], d[i][0]);add(d[i][8], d[i][0]);if(i>1)add(d[i-2][0], d[i][0]);add(d[i][0], d[i+1][1]);add(d[i][0], d[i+1][3]);add(d[i][0], d[i+1][5]);add(d[i][0], d[i+1][7]);add(d[i][1], d[i+1][4]);add(d[i][2], d[i+1][4]);add(d[i][3], d[i+1][2]);add(d[i][4], d[i+1][2]);add(d[i][5], d[i+1][8]);add(d[i][6], d[i+1][8]);add(d[i][7], d[i+1][6]);add(d[i][8], d[i+1][6]);}int T, n;scanf("%d", &T);while(T--){scanf("%d", &n);printf("%d\n", d[n][0]);}return 0;}