3和4WA,不知道bug在哪,恳请大佬指点
查看原帖
3和4WA,不知道bug在哪,恳请大佬指点
921159
hy65y楼主2023/1/28 17:11
#include<iostream>
using namespace std;
long long num[30][30];
bool is_horse(int m, int n, int x, int y)
{
	if (m == x && n == y)
		return true;
	else if ((m - x) * (n - y) == 2)
		return true;
	else if ((m - x) * (n - y) == -2)
		return true;
		return false;
}
int path_num(int m,int n,int x,int y)
{
	if (is_horse(m,n,x,y))
		return 0;
	if (m == 0 && n == 0)
		return 1;
	if (num[m][n] > 0)
		return num[m][n];
	int count = 0;
	if (m>0)
		count += path_num(m - 1, n, x, y);
	if (n>0)
		count += path_num(m, n - 1, x, y);
	num[m][n] = count;
	return count;
}
int main() {

	int x, y = 0;
	int m, n = 0;
	cin >> m >> n >> x >> y;
	cout << path_num(m, n, x, y) << endl;


	return 0;
}
2023/1/28 17:11
加载中...