题解 | #[NOIP2002 普及组] 过河卒#
[NOIP2002 普及组] 过河卒
https://www.nowcoder.com/practice/cc1a9bc523a24716a117b438a1dc5706
#include <iostream> using namespace std; long long dp[22][22]; int main() { int n,m,x,y; cin >> n >> m >> x >> y; //映射坐标 x += 1; y += 1; //初始化 dp[0][1] = 1; //遍历 for(int i = 1;i <= n+1; i++) { for(int j = 1;j <= m+1; j++) { //极端情况的处理: 1.马控制点 2.自身重合 if((i != x && j != y && abs(i - x) + abs(j - y) == 3) || (i == x && j == y)) { dp[i][j] = 0; } else { dp[i][j] = dp[i][j-1] + dp[i-1][j]; } } } cout << dp[n+1][m+1] << endl; return 0; }