60分求助!

P1002 [NOIP2002 普及组] 过河卒

@[paulpao](/user/717437) 马自己所在的点算了吗
by TankYu @ 2023-05-31 21:39:26


```cpp x[hx][hy]=1; ``` @[TankYu](/user/408071) 算了,就是这一条
by paulpao @ 2023-06-01 11:09:36


```cpp #include <iostream> using namespace std; long long f[22][22]; bool ctrl[22][22]; int n, m, x, y; int d[9][2] = {2,1,1,2,-1,2,-2,1,-2,-1,-1,-2,1,-2,2,-1}; int main(){ cin>>n>>m>>x>>y; for (int i = 0;i<=8;i++){ int tx = x+d[i][0], ty = y+d[i][1]; if (tx>=0&&ty>=0&&tx<=n&&ty<=m){ ctrl[tx][ty] = true; } } if (ctrl[0][0]) { cout<<0; return 0; } f[0][0] = 1; for (int i = 0;i<=n;i++) for (int j = 0;j<=m;j++){ if(ctrl[i][j]) continue; if (i) f[i][j]+=f[i-1][j]; if (j) f[i][j]+=f[i][j-1]; } cout<<f[n][m]; return 0; } ```
by Tx1234567 @ 2023-06-01 19:43:27


|