求大佬帮看看!! #WA 3,4
查看原帖
求大佬帮看看!! #WA 3,4
524906
刘辰雨楼主2021/10/18 13:26
#include<bits/stdc++.h>
using namespace std;
long long a[40][40];
int m , n , mx , my ;
const int fx[10] = {0,-1,1,2,2,1,-1,-2,-2};
const int fy[10] = {0,2,2,1,-1,-2,-2,-1,1};
bool pd(int x , int y)
{
	int X,Y;
	for(int i = 0 ; i <= 8 ; i++ )
	{
		X = mx + fx[i];
		Y = my + fy[i];
		if(X == x && Y == y)	return false;
	}
	return true;
}
int main()
{
	cin>>n>>m>>mx>>my;
	n++;m++;mx++;my++;
	for(int i = 1 ; i <= n ; i++ )	if(pd(i,1))	a[i][1] = 1;
	for(int i = 1 ; i <= m ; i++ )	if(pd(1,i))	a[1][i] = 1;
	for(int i = 2 ; i<= n ; i++ )
		for(int j = 2 ; j <= m ; j++ )
			if(pd(i,j))	a[i][j] = a[i-1][j] + a[i][j-1];
	for(int i = 1 ; i<= n ; i++ )
	{
		for(int j = 1 ; j <= m ; j++ )
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<a[n][m];
} 
2021/10/18 13:26
加载中...