我使用的是dfs算法
#include <iostream>
#include <cstring>
using namespace std;
int P1002_ANS = 0;
int bx,by,hx,hy;
bool map[20][20];
void P1002_dfs(int x,int y){
if (x==bx&&y==by){P1002_ANS++;return;}
else if (x>bx||y>by) return;
if (map[x+1][y]!=false&&!(x+1>bx)&&!(y>by)) P1002_dfs(x+1,y);
if (map[x][y+1]!=false&&!(x>bx)&&!(y+1>by)) P1002_dfs(x,y+1);
}
int main(){
cin >> bx >> by >> hx >> hy;
memset(map, true, sizeof(map));
map[hx][hy] = map[hx-1][hy-2] = map[hx-2][hy-1] = map[hx-2][hy+1] =
map[hx-1][hy+2] = map[hx+1][hy+2] = map[hx+2][hy+1] = map[hx+2][hy-1] =
map[hx+1][hy-2] = false;
P1002_dfs(0,0);
cout << P1002_ANS << endl;
return 0;
}