0分求助
查看原帖
0分求助
832559
ZHANGHUAYU666楼主2024/6/23 14:57
#include<bits/stdc++.h>
using namespace std;
bool v[25][25];
int ix[8]={-1,1,-2,2,-2,2,-1,1};
int iy[8]={2,2,1,1,-1,-1,-2,-2};
int n,m,stx,sty,dp[25][25];
bool check(int px,int py)
{
	if(px<0||px>n||py<0||py>m) return false;
	return true;
}
int main()
{
	cin>>n>>m>>stx>>sty;
	v[stx][sty]=true;
	for(int i=0;i<8;i++)
	{
		int ox=ix[i]+stx;
		int oy=iy[i]+sty;
		if(check(ox,oy)==false) continue;
		v[ox][oy]=true;
	}
	dp[0][0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i+j==0)
			{
				continue;
			} 
			else if(v[i][j]) 
			{
				continue;
			}
			else dp[i][j]=dp[i-1][j]+dp[i][j-1];
		}
	}
	cout<<dp[n][m]<<endl; 
    return 0;
}

我把第一个样例下载出来,自测是对的,但提交后是错的!

2024/6/23 14:57
加载中...