直达:https://www.luogu.com.cn/problem/P1002
AC 代码:
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 30;
long long a[MAXN][MAXN];
bool vis[MAXN][MAXN];
int n,m,x,y,nx,ny;
int dir[8][2] = {{2,1},{1,2},{-1,2},{-2,1},{-2,-1},{-1,-2},{1,-2},{2,-1}};
int main() {memset(vis,0,sizeof vis);cin >> n >> m >> x >> y;vis[x][y] = true;for (int i = 0; i < 8; i++) {nx = x + dir[i][0];ny = y + dir[i][1];if (0 <= nx && nx <= n && 0 <= ny && ny <= m) {vis[nx][ny] = true;}}for (int i = 1; i <= n; i++) {if (vis[i][0] == false) a[i][0] = 1;else break;}for (int i = 1; i <= m; i++) {if (vis[0][i] == false) a[0][i] = 1;else break;}for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (vis[i][j] == false) a[i][j] = a[i][j-1] + a[i-1][j];cout << a[n][m] << endl;return 0;
}
sub plz