求助!!!!!!!
  • 板块灌水区
  • 楼主laijingyun
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/8/10 11:22
  • 上次更新2024/8/10 12:11:07
查看原帖
求助!!!!!!!
1176947
laijingyun楼主2024/8/10 11:22

大佬哪里错了???

#include<bits/stdc++.h>
using namespace std;
char qp[30][30];
long long ma1,ma2,n,m,cnt=0,fx,fy;
long long zl[2][2]={{1,0},{0,1}};
long long ma[9][2]={{0,0},{1,2},{2,1},{2,-1},{1,-2},{-1,-2},{-2,-1},{-2,1},{-1,2}};
void horse(long long a,long long b){
	if(a==n && b==m){
		cnt++;
		return;
	}
	for(int i=0;i<2;i++){
		fx=a+zl[i][0];
		fy=b+zl[i][1];
		if(fx>n || fy>m) continue;
		if(qp[fx][fy]=='.'){
			horse(fx,fy);
		}
	}
}
int main() {
	long long fxx,fyy;
	cin>>n>>m>>ma1>>ma2;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			qp[i][j]='.';
		}
	}
	for(int j=0;j<9;j++){
		fxx=ma1+ma[j][0];
		fyy=ma2+ma[j][1];
		if(fxx<0 || fyy<0 || fxx>n || fyy>m) continue;
		qp[fxx][fyy]='#';
	}
	horse(0,0);
	cout<<cnt;
	return 0;
}
2024/8/10 11:22
加载中...