# 求助

@Brooksx 2021-07-02 18:55 回复
#include <cstdio>
int c[21][21];
int main() {
c[1][1] = 1;
int n, m, x, y;
scanf("%d %d %d %d", &n, &m, &x, &y);
int v[4][2] = {{n - 2, m - 1}, {n - 2, m + 1}, {n - 1, m - 2}, {n + 1, m-2}};
for (int i = 0; i < 4; i++) {
c[v[i][0]][v[i][1]] = -1;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (c[i][j] = -1) continue;
c[i][j] = c[i-1][j] + c[i][j-1];
if (c[i-1][j] == -1) c[i][j] ++;
if (c[i][j-1] == -1) c[i][j] ++;
}
}
printf("%d", c[n][m]);
return 0;
}

@TakuChen 2021-07-02 19:29 回复 举报
#include <cstdio>
#include<iostream>
using namespace std;
int c[31][31];
long long ans[30][30];
int d[9][2]={{0,0},{1,2},{1,-2},{-1,2},{-1,-2},
{2,1},{2,-1},{-2,1},{-2,-1}};
int n, m, x, y;
int main() {

cin>>n>>m>>x>>y;
for (int i = 0; i < 9; i++) {
int tmx=x+d[i][0],tmy=y+d[i][1];
if(tmx>=0&&tmx<=n&&tmy>=0&&tmy<=m){
c[tmx][tmy]=1;
}

}
ans[0][0]=1-c[0][0];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
if (c[i][j] ) continue;
if (i!=0) ans[i][j]+=ans[i-1][j];
if (j!=0) ans[i][j]+=ans[i][j-1];
}
}
cout<<ans[n][m];
return 0;
}
@TakuChen 2021-07-02 19:34 回复 举报

1.马可以跳8个点

2.判断有没有越界

3.

 ans[0][0]=1-c[0][0];