助
查看原帖
助
1031699
GECSD楼主2024/6/16 20:01

助

#include <bits/stdc++.h>
using namespace std;
long long chess[30][30];
bool chees[30][30];
int dh1[10]={0,-1, 1, 2, 2,1,-1,-2,-2};
int dh2[10]={0,-2,-2,-1, 1,2, 2, 1,-1};
int main()
{
	int b1,b2,h1,h2;
	cin>>b1>>b2>>h1>>h2;
	b1+=3;b2+=3;h1+=3;h2+=3;chess[3][3]=1;
	for(int i=1;i<=8;i++)
	{
		int new_h1=h1+dh1[i];
		int new_h2=h2+dh2[i];
		chees[new_h1][new_h2]=true;
	}
	for(int i=3;i<=b1;i++)
		for(int j=3;j<=b2;j++)
		{
			if(chees[i][j]==true)
				continue;
			chess[i][j]+=(chess[i-1][j]+chess[i][j-1]);
		}
	cout<<chess[b1][b2];
	return 0;
}
2024/6/16 20:01
加载中...