感觉没什么问题[流汗],求调,希望可以指出问题
  • 板块P1644 跳马问题
  • 楼主xjx199
  • 当前回复11
  • 已保存回复11
  • 发布时间2024/1/20 19:00
  • 上次更新2024/1/20 21:26:10
查看原帖
感觉没什么问题[流汗],求调,希望可以指出问题
550898
xjx199楼主2024/1/20 19:00
#include<bits/stdc++.h>
using namespace std;
int n,m,tx,ty,ans,vis[10001][10001];
int dx[4]={1,2,2,1};
int dy[4]={2,1,-1,-2};
void dfs(int x,int y)
{
	if(x==n&&y==m)
	{
		ans++;
		return;
	}
	for(int i=0;i<2;i++)
	{
		tx=x+dx[i];
		ty=y+dy[i];
		if(tx>=0&&tx<=n&&ty>=0&&ty<=m&&!vis[tx][ty])
		{
			vis[x][y]=1;
			dfs(tx,ty);
			vis[x][y]=0;
		}
	}
}
int main()
{
	cin>>n>>m;
	dfs(0,0);
	cout<<ans;
	return 0;
}
2024/1/20 19:00
加载中...