如题
#include<cstdio>
using namespace std;
long long ans[25][25];
struct pos{
int x,y;
}B,C,P[7];
const int x[]={2,1,-1,-2,-2,-1,1,2},y[]={1,2,2,1,-1,-2,-2,-1};
int main(){
scanf("%d%d%d%d",&B.x,&B.y,&C.x,&C.y);
for(int i=0;i<8;i++){
P[i].x=C.x+x[i];
P[i].y=C.y+x[i];
}
ans[0][0]=1;
if(P[5].x!=1)
for(int i=0;i<=B.y;i++)
ans[1][i]=1;
else{
for(int i=0;i<P[5].y;i++)
ans[1][i]=1;
for(int i=P[5].y;i<=B.y;i++)
ans[1][i]=0;
}
for(int i=1;i<=B.x;i++)
for(int j=1;j<=B.y;j++){
bool flag=1;
if(i==C.x&&j==C.y)
flag=0;
for(int k=0;k<8;k++)
if(i==P[i].x&&j==P[i].y)
flag=0;
if(flag)
ans[i][j]=ans[i-1][j]+ans[i][j-1];
else
ans[i][j]=0;
}
printf("%lld",ans[B.x][B.y]);
return 0;
}