dalao们60分求调
查看原帖
dalao们60分求调
1041398
ZZZZZhanggggg楼主2024/7/22 15:49

60分求调

#include <bits/stdc++.h>
using namespace std;
long long DP[22][22];
long long B[22][22];
int DX[8] = {1, 1, 2, 2, -1, -1, -2, -2};
int DY[8] = {2, -2, 1, -1, 2, -2, 1, -1};
int main()
{
	long long bx, by, hx, hy;
	cin >> bx >> by >> hx >> hy;
	B[hx][hy] = 1;
	for (int i = 0; i < 8; i++)
	{
		long long newx = hx + DX[i];
		long long newy = hy + DY[i];
		if (hx + DX[i] >= 0 && hx + DX[i] <= 20 && hy + DX[i] >= 0 && hy + DX[i] <= 20)
		{
			B[newx][newy] = 1;
		}
	}
	DP[0][0] = 1;
    
	for (int i = 0; i <= bx; i++)
	{
		for (int j = 0; j <= by; j++)
		{
			if (i == 0 && j == 0)
			{
				continue;
			}
			long long upw, lfw = 0;
                if(i-1>-1)
				upw = DP[i - 1][j];
                if(j-1>-1)
				lfw = DP[i][j - 1];
			if (B[i][j] == 0)
			{
				DP[i][j] = upw + lfw;
			}
		}
	}
	cout << DP[bx][by];
    system("pause");
	return 0;
}
2024/7/22 15:49
加载中...