为什么错了
查看原帖
为什么错了
1617490
heboyue303楼主2024/12/28 15:49
#include<bits/stdc++.h>
using namespace std;
int bx,by,mx,my;
int dp[50][50];
bool chick(int i,int j,int mx,int my){
	if(i==mx&&j==my)return true;
	else if(i==mx+1&&j==my+2)return true;
	else if(i==mx+1&&j==my-2)return true;
	else if(i==mx-1&&j==my+2)return true;
	else if(i==mx-1&&j==my-2)return true;
	else if(i==mx+2&&j==my+1)return true;
	else if(i==mx+2&&j==my-1)return true;
	else if(i==mx-2&&j==my+1)return true;
	else if(i==mx-2&&j==my-1)return true;
	else return false;
}
int main(){
	cin>>bx>>by>>mx>>my;
	for(int i=0;i<=bx;i++){
		for(int j=0;j<=by;j++){
			if(i==0||j==1)dp[i][j]=1;
			else{
				if(!chick(i,j,mx,my)){
					dp[i][j]=dp[i-1][j]+dp[i][j-1];
				}
				else dp[i][j]=0;
			}
			
		}
	}
	cout<<dp[bx][by];
	
	return 0;
}

2024/12/28 15:49
加载中...