不知道怎么调
查看原帖
不知道怎么调
1111574
a15207081682楼主2025/7/30 11:56
#include <iostream>
using  namespace std;

int chess[50][50];

static int f(int m, int n, int a, int b) {

	if(a==m&&b==n) {
		return 1;
	}
  
	if (a==m||chess[a+1][b]==1) {
		return f(m, n, a, b + 1);
	}
  
	if (b==n||chess[a][b+1]==1) {
		return f(m, n, a + 1, b);
	}
  
	return f(m, n, a + 1, b) + f(m, n, a, b + 1);

}

int main() {

	int m, n, x, y;
	cin >> m >> n >> x >> y;
	m += 2, n += 2, x += 2, y += 2;
	chess[x][y] = 1;
	chess[x - 1][y - 2] = 1;
	chess[x + 1][y - 2] = 1;
	chess[x - 1][y + 2] = 1;
	chess[x + 1][y + 2] = 1;
	chess[x - 2][y - 1] = 1;
	chess[x - 2][y + 1] = 1;
	chess[x + 2][y - 1] = 1;
	chess[x + 2][y + 1] = 1;
	int a = 2, b = 2;
	cout << f(m, n, a, b);

	return 0;
}
2025/7/30 11:56
加载中...