萌新0分的求助
查看原帖
萌新0分的求助
482623
一洛本谷通楼主2022/3/6 15:07
#include<bits/stdc++.h>
using namespace std;
int n, m, total;
int  nxt[4][2] = {2, 1, 1, 2, -1, 2, -2, 1};
void dfs(int x, int y) {
	if (x < 0 || x > n || y > n) return ;
	if (x == n || y == m) total++;
	else{	
		for (int i = 0; i < 4; i++) {
			int nx = x + nxt[i][0];
			int ny = y + nxt[i][1];
			dfs(nx, ny);
		}
	}
}
int main() {
	cin >> n >> m;
	dfs(0, 0);
	cout << total;
	return 0;
}

鄙人认为思路没有错,劳驾各位大神看看鄙人的拙作

2022/3/6 15:07
加载中...