颠倒相等可意象为中心对称
中间位只能是1,8,0
在确定左侧的情况下右侧也可确定
所以为
C
5
1
C_5^1
C51+
C
5
2
C_5^2
C52+
C
5
3
C_5^3
C53=75
最优情况:左右平均
最差情况:mink为1或n
在最优情况下为完全二叉树,深度最浅
最差情况深度为n
#include <cstdio>
using namespace std;
int n;
const int max_size = 1 << 10;
int res[max_size][max_size];
void recursive(int x, int y, int n, int t) {
if (n == 0) {
res[x][y] = ①;
return;
}
int step = 1 << (n - 1);
recursive(②, n - 1, t);
recursive(x, y + step, n - 1, t);
recursive(x + step, y, n - 1, t);
recursive(③, n - 1, !t);
}
int main() {
scanf("%d", &n);
recursive(0, 0, ④);
int size = ⑤;
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++)
printf("%d", res[i][j]);
puts("");
}
return 0;
}