为什么同样的题同样的代码在洛谷上就能过在一本通上就过不了啊!!!
查看原帖
为什么同样的题同样的代码在洛谷上就能过在一本通上就过不了啊!!!
325404
Boar楼主2020/7/25 09:49
#include<bits/stdc++.h> 
using namespace std;
long f[30][30];//记忆化搜索
int n,m,x,y,way[9][2]={{0,0},{1,2},{-1,-2},{2,1},{-2,-1},{1,-2},{-1,2},{-2,1},{2,-1}};
long seek(int x1,int y1){
	if(f[x1][y1]) return f[x1][y1];
	for(int i=0;i<9;i++)
		if(x1==x+way[i][0] && y1==y+way[i][1]) return 0;//检验是否会被踩
	long ans=x1?seek(x1-1,y1):0;
	ans+=y1?seek(x1,y1-1):0;
	f[x1][y1]=ans;
	return ans;
}
int main(){
	cin>>n>>m>>x>>y;
	memset(f,0,sizeof(f));
	f[0][0]=1;
	cout<<seek(n,m);
	return 0;
}
2020/7/25 09:49
加载中...