60WA,qz
查看原帖
60WA,qz
1233308
QoQ_楼主2024/6/13 22:06

题解的思路,60分

#include<bits/stdc++.h>
using namespace std;
int x[10]={0,-2,-1,1,2,2,1,-1,-2};
int y[10]={0,1,2,2,1,-1,-2,-2, 1};
bool maps[502][502];
long long dp[503][500],hx,hy,bx,by;
int main(){
	cin>>bx>>by>>hx>>hy;
	bx+=2;
	by+=2;
	hx+=2;
	hy+=2;
	dp[2][1]=1;
	maps[hx][hy]=true;
	for(int i=1;i<=8;i++){
		long long xs=hx+x[i];
		long long xy=hy+y[i];
		maps[xs][xy]=true;
	}
	for(int i=2;i<=bx;i++){
		for(int j=2;j<=by;j++){
			if(maps[i][j]==true){
				continue;
			}else if(maps[i][j]==false){
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
			}
		}
	}
	cout<<dp[bx][by]<<"\n";
	return 0;
}
2024/6/13 22:06
加载中...