# 80分

@Rover 2020-08-26 21:57 回复

#include <cstdio>
#include <cstring>
using namespace std;

const int movx[] = {0, -1, +1, -1, +1, -2, -2, +2, +2};
const int movy[] = {0, -2, -2, +2, +2, -1, +1, -1, +1};

int main()
{
long long n, m, hn, hm;
scanf("%lld %lld %lld %lld", &n, &m, &hn, &hm);
long long a[n + 2][m + 2];
for (int i = 0; i <= n + 1; i++)
for (int j = 0; j <= m + 1; j++)
a[i][j] = 0;
for (int i = 0; i <= 8; i++)
{
int ta = hn + movx[i] + 1, tb = hm + movy[i] + 1;
if (ta >= 1 && ta <= n && tb >= 1 && tb <= m)
a[ta][tb] = -1;
}
a[2][0] = 1, a[0][2] = 1;
for (int i = 1; i <= n + 1; i++)
for (int j = 1; j <= m + 1; j++)
if (a[i][j] == -1)
a[i][j] = 0;
else
a[i][j] = a[i - 1][j] + a[i][j - 1];
// for (int i = 1; i <= n + 1; i++)
// {
//     for (int j = 1; j <= m + 1; j++)
//         printf("%4lld ", a[i][j]);
//     putchar('\n');
// } //用来查图的
printf("%lld", a[n + 1][m + 1]);
return 0;
}
@zyk7 2020-08-26 22:06 回复 举报

@Rover 主函数第10行代码那个判断应改为

if (ta >= 1 && ta <= n+1 && tb >= 1 && tb <= m+1)