求助

P1002 [NOIP2002 普及组] 过河卒

@[Brooksx](/user/529247) ```cpp #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; } ```
by TakuChen @ 2021-07-02 19:29:46


@[Brooksx](/user/529247) 不知道为啥不能用scanf和printf要不然会错两个点
by TakuChen @ 2021-07-02 19:30:43


@[Brooksx](/user/529247) 1.马可以跳8个点 2.判断有没有越界 3. ```cpp ans[0][0]=1-c[0][0]; ``` 的作用是如果这个点马走不到那ans[0][0]是1,否则是0
by TakuChen @ 2021-07-02 19:34:30


@[TakuChen](/user/358194) 只写了四个点是我忘了。。
by Br00k5xx @ 2021-07-02 19:42:00


@[Brooksx](/user/529247) 头打错了
by pmxin163 @ 2021-07-08 16:22:41


@[pmxin163](/user/528336) ???
by Br00k5xx @ 2021-07-08 18:26:23


|