求助大佬,#3#4不过
查看原帖
求助大佬,#3#4不过
1544661
Pirate123楼主2024/10/26 19:30
#include<stdio.h>
int main() {
	long long int  b1,b2,h1,h2;
	long long int h[9][2] = { {0,0},{2,1}, {1,2}, {-1,2}, { -2,1}, { -2,-1}, { -1,-2}, {1,-2}, {2,-1} };
	scanf("%lld %lld", &b1, &b2);
	scanf("%lld %lld", &h1,&h2);
	for (int i = 0; i <= 8; i++)
	{
		h[i][0] += h1;
		h[i][1] += h2;
	}
	int c[21][21] = {(0,0)};
	c[0][0] = 1;
	for (int i = 0; i <= 8; i++)
	{
		if(h[i][0]>=0&&h[i][1]>=0&& h[i][0] < 21&& h[i][0] <21)c[h[i][0]][h[i][1]] = -1;
	}
	for (int x = 0; x <= b1; x++)
	{
		for (int y = 0; y <= b2; y++)
		{
			if (c[x][y] != -1 && x - 1 >= 0 && c[x - 1][y] != -1)c[x][y] += c[x-1][y];
			if (c[x][y] != -1 && y - 1 >= 0 && c[x][y-1] != -1)c[x][y] += c[x][y-1];
		}
	}
	printf("%d\n",c[b1][b2]);
	return 0;
}
2024/10/26 19:30
加载中...