跟P1605和像
#include <iostream>
#include <stack>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <cstring>
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int vis[20][20];
int dx[4] = { 1,2,2,1 };//上到下
int dy[4] = { -2,-1,1,2 };
int n, m,ans;
void dfs(int x1,int y1)
{
if (x1 == m && y1 == n)
{
ans++;
return;
}
vis[x1][y1] = 1;
for (int i = 0; i < 4; i++)
{
int tempx = x1 + dx[i];
int tempy = y1 + dy[i];
if (tempx <= m && tempx >= 0 && tempy >= 0 && tempy <= n && vis[tempx][tempy] == 0)
dfs(tempx, tempy);
}
vis[x1][y1] = 0;
}
signed main()
{
cin >> n >> m;
dfs(0, 0);
cout << ans << endl;
return 0;
}