题解
2025-09-01 20:53:50
发布于:广东
5阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
long long a[25][25];
bool c[25][25];
int dx[9] = {0,-2,-1,1,2,2,1,-1,-2};
int dy[9] = {0,1,2,2,1,-1,-2,-2,-1};
int main(){
int n,m,x,y;
cin >> n >> m >> x >> y;
x += 1,y += 1;
for(int i = 0;i <= 8;i++){
int ax = x + dx[i];
int ay = y + dy[i];
if(ax > 0 && ax <= n + 1 && ay > 0 && ay <= m + 1) c[ax][ay] = true;
}
a[1][1] = 1;
for(int i = 1;i <= n + 1;i++){
for(int j = 1;j <= m + 1;j++){
if(a[i][j]){
continue;
}
if(c[i][j]){
continue;
}
a[i][j] = a[i - 1][j] + a[i][j - 1];
}
}
cout << a[n + 1][m + 1];
return 0;
}
这里空空如也
有帮助,赞一个