0pts求助
查看原帖
0pts求助
972511
Ljh421楼主2024/3/21 17:16
#include <bits/stdc++.h>
using namespace std;
int a[21][21],book[21][21];
int bx,by,ax,ay;
int xxx[5]={0,1,0};
int yyy[5]={0,0,1};
int sum;
void dfs(int x,int y){
	if(x==bx&&y==by){
		sum++;
		return;
	}
	for(int i=1;i<=2;i++){
		int xx=x+xxx[i];
		int yy=y+yyy[i];
		if(xx>=1&&xx<=bx&&yy>=1&&yy<=by&&book[xx][yy]==0){
			dfs(xx,yy);
		}
	}
	return;
}
int main(){
	
	
	cin>>bx>>by>>ax>>ay;
	
	book[ax-2][ay-1]=1;
	book[ax-1][ay-2]=1;
	book[ax+1][ay-2]=1;
	book[ax+2][ay-1]=1;
	book[ax+2][ay+1]=1;
	book[ax+1][ay+2]=1;
	book[ax-1][ay+2]=1;
	book[ax-2][ay+1]=1;
	
	book[0][0]=1;
	dfs(0,0);
	cout<<sum;

	return 0;
}

2024/3/21 17:16
加载中...