测试点4不过,求助!

P1002 [NOIP2002 普及组] 过河卒

@[Mr_LiuXinan](/user/1229013) 兵卒是可以到x或y为0的坐标上的所以标记马阻挡的地方那几个判断的 > 都改成 >= 就可以了
by tankewei911 @ 2024-02-19 16:29:09


我用你的代码改了一下就AC了!! ```cpp #include <iostream> using namespace std; long long xb, yb, xh, yh, pos[100][100], book[100][100]; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> xb >> yb >> xh >> yh; pos[0][0] = 1; book[xh][yh] = 1; if (xh >= 2 && yh >= 1) book[xh - 2][yh - 1] = 1; if (xh >= 1 && yh >= 2) book[xh - 1][yh - 2] = 1; if (yh >= 1) book[xh + 2][yh - 1] = 1; if (yh >= 2) book[xh + 1][yh - 2] = 1; if (xh >= 2) book[xh - 2][yh + 1] = 1; if (xh >= 1) book[xh - 1][yh + 2] = 1; book[xh + 2][yh + 1] = 1; book[xh + 1][yh + 2] = 1; for (int i = 1; i <= xb; ++i) { if (book[i][0] == 0) pos[i][0] = pos[i - 1][0]; } for (int i = 1; i <= yb; ++i) { if (book[0][i] == 0) pos[0][i] = pos[0][i - 1]; } for (int i = 1; i <= xb; ++i) { for (int j = 1; j <= yb; ++j) { if (book[i][j] == 0) pos[i][j] = pos[i - 1][j] + pos[i][j - 1]; } } cout << pos[xb][yb]; return 0; } ```
by tankewei911 @ 2024-02-19 16:30:11


OK
by Mr_LiuXinan @ 2024-02-20 08:36:40


@[tankewei114514sb](/user/952747) ok,感谢
by Mr_LiuXinan @ 2024-02-20 08:37:27


|