80分
查看原帖
80分
231423
AquerKing楼主2020/8/26 21:57

写了好久代码,从60到40到0到80。

不说了,都是泪。 劳烦犇犇可以帮我找下BUG,感谢!!!

错在数据一,惭愧……输出就比数据大了1.

#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;
}
2020/8/26 21:57
加载中...