dfs0分求助!!!
查看原帖
dfs0分求助!!!
477032
diandian2020楼主2021/2/28 08:11
#include<cstdio>
int n,m,tot;
void dfs(int a,int b){
	if(a>n||a<1||b>m||b<1) return;
	if(a==n&&b==m){
		tot++;
	}
	else{
		dfs(a+1,b+2);
		dfs(a+2,b+1);
		dfs(a-2,b+1);
		dfs(a-1,b+2);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	dfs(0,0);
	printf("%d",tot);
	return 0;
}
2021/2/28 08:11
加载中...