#include using namespace std; const int N = 15; typedef pair PII; int n, m; int res; int dx[] = {-1, 0, 1, 0}; // 上右下左 int dy[] = {0, 1, 0, -1}; // 上右下左 int st[N][N]; void dfs(int x, int y, int cnt) { if (x == 1 && y == 1 && cnt == m * n) { res++; return; } for (int i = 0; i < 4; i++) { int tx = x + dx[i], ty = y + dy[i]; if (tx == 0 || tx > n || ty == 0 || ty > m) continue; if (!st[tx][ty]) { st[tx][ty] = 1; dfs(tx, ty, cnt + 1); st[tx][ty] = 0; } } } int main() { cin >> n >> m; dfs(1, 1, 0); printf("%d\n", res); return 0; } /** 测试数据: 3 4 答案: 4 */