文章
68
粉丝
691
获赞
26
访问
578.4k
#define ll long long
#define vec vector<int>
#define inf 0x3f3f3f3f
#define MAX 25
#define P pair<int,int>
#define MOD 1000000
ll n, m, sx, sy, a[MAX][MAX], ma[MAX][MAX], x, y;
int dx[9] = { 0,1,2,2,1,-1,-2,-2,-1 }, dy[9] = { 0,-2,-1,1,2,-2,-1,1,2 };
int main() {
while (cin >> n >> m >> sx >> sy) {
memset(a, 0, sizeof(a));
memset(ma, 0, sizeof(ma));
for (int i = 0; i < 9; i++) {
x = sx + dx[i], y = sy + dy[i];
if (x < 0 || x > n || y < 0 || y > m)continue;
else ma[x][y] = 1;
}
a[0][0] = 1;
for (int i = 1; i <= n&&ma[i][0] != 1; i++) a[i][0] = 1;
for (int i = 1; i <= m&&ma[0][i] != 1; i++) a[0][i] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (ma[i][j] == 1)continue;
a[i][j] = a[i - 1][j] + a[i][j - 1];
}
}
cout << a[n][m] << endl;
}
}
登录后发布评论
暂无评论,来抢沙发