标题:方格分割
6x6的方格,沿着格子的边线剪开成两部分。
要求这两部分的形状完全相同。
试计算:
包括这3种分法在内,一共有多少种不同的分割方法。
注意:旋转对称的属于同一种分割法。
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
int d[4][2] = { -1,0,1,0,0,1,0,-1 };
int a[10][10];
bool vis[10][10];
int res;
void dfs(int x, int y) {
if (x == 0 || x == 6 || y == 0 || y == 6) {
++res;
return;
}
for (int i = 0; i < 4; i++) {
int nx = x + d[i][0];
int ny = y + d[i][1];
if (!vis[nx][ny] && nx >= 0 && nx <= 6 && ny >= 0 && ny <= 6) {
vis[x][y] = vis[6 - x][6 - y] = true;
dfs(nx, ny);
vis[nx][ny] = vis[6 - nx][6 - ny] = 0;
}
}
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
vis[3][3] = 1;
dfs(3, 3);
cout << res / 4 << '\n';
}