题解

凌艺樽  •  5个月前


挖去,这题搞s人了

#include <bits/stdc++.h>
using namespace std;
const int N=30;
const int INF=0x3f3f3f3f;
int n,m;
long long a[N][N],x,y;
int main()
{
	cin>>n>>m>>x>>y;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0 && j==0)
			{
				a[i][j]=1;
			}
			else if(abs(x-i)==2 && abs(y-j)==1)
			{
				a[i][j]=0;
			}
			else if(abs(x-i)==1 && abs(y-j)==2)
			{
				a[i][j]=0;
			}
			else if(i==x && j==y)
			{
				a[i][j]=0;
			}
			else if(i==0)
			{
				a[i][j]=a[i][j-1];
			}
			else if(j==0)
			{
				a[i][j]=a[i-1][j];
			}
			else
			{
				a[i][j]=a[i-1][j]+a[i][j-1];
			}
		}
	}
	cout<<a[n][m];
	return 0;
}


评论: