求助
查看原帖
求助
696955
qinwenjun楼主2022/7/13 21:27
#include<bits/stdc++.h>
using namespace std;
int n, m, x, y;
int dx[10] = {0, -1, -2, -2, -1, +1, +2, +2, +1};
int dy[10] = {0, -2, -1, +1, +2, +2, +1, -1, -2};
long long f[30][30];
int main(){
	cin>>n>>m>>x>>y;
	f[x][y]=-1;
	for(int i=1;i<=8;i++){
		int xx=x+dx[i],yy=y+dy[i];
		if(xx>=1&&xx<=n&&yy>=1&&yy<=m) f[xx][yy]=-1;
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(f[i][j]!=-1){
				if(f[i-1][j]!=-1) f[i][j]=+f[i-1][j];
				if(f[i][j-1]!=-1) f[i][j]=+f[i][j-1];
			}
		}
	}
	if (f[n][m]==-1) cout<<0;
	else cout<<f[n][m];
	return 0;
}
2022/7/13 21:27
加载中...