三四点错了,求大佬帮助(悲
查看原帖
三四点错了,求大佬帮助(悲
782192
Delicious_Bread楼主2022/9/4 18:22
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int horse(long long a[21][21],long x,long y,long m,long n)
{
	if(x>=0&&x<=m&&y>=0&&y<=n)
	{
		a[x][y] = 0;	
	}
}
int main()
{
	long m,n,x,y;
	cin>>m>>n>>x>>y;
	if((x==0&&y==0)||(x==m&&y==n))
	{
		cout<<0<<endl;
		return 0;
	}
	long long a[21][21];
	memset(a,-1,sizeof(a));
	for(int i=0;i<=m;++i)
	{
		a[i][0] = 1;
	}
	for(int i=0;i<=n;++i)
	{
		a[0][i] = 1;
	}
	a[x][y] = 0;
	horse(a,x+1,y+2,m,n);
	horse(a,x+1,y-2,m,n);
	horse(a,x+2,y+1,m,n);
	horse(a,x+2,y-1,m,n);
	horse(a,x-1,y+2,m,n);
	horse(a,x-1,y-2,m,n);
	horse(a,x-2,y+1,m,n);
	horse(a,x-2,y-1,m,n);	
 	for(int i=1;i<=m;++i)
 	{
 		for(int j=1;j<=n;++j)
 		{
 			if(a[i][j]==-1)
 			{
 				a[i][j] = a[i-1][j]+a[i][j-1];		
			}
		}
	}
	cout<<a[m][n]<<endl;
	return 0;
 } 
 ```cpp
2022/9/4 18:22
加载中...