P1002 [NOIP2002 普及组] 过河卒
#include
#include
#include
#include
#include
#pragma warning(disable:4996);
using namespace std;
const int maxn = 110;
long long dp[maxn+1][maxn+1];
bool b[maxn][maxn];int dx[8] = { 1,1,2,2,-1,-1,-2,-2 };
int dy[8] = { 2,-2,1,-1,2,-2,1,-1 };
int C_x, C_y, B_x, B_y;bool isHourse(int x, int y)
{for (int i &#61; 0; i < 8; i&#43;&#43;){if (C_x &#43; dx[i] &#61;&#61; x && C_y &#43; dy[i] &#61;&#61; y){return true;}}return false;
}int main()
{cin >> B_x >> B_y >> C_x >> C_y;memset(b, false,sizeof(b));b[C_x][C_y] &#61; true;for (int i &#61; 0; i < 8; i&#43;&#43;){if (C_x &#43; dx[i] >&#61; 0 && C_x &#43; dx[i] <&#61; B_x && C_y &#43; dy[i] <&#61; B_y && C_y &#43; dy[i] >&#61; 0){b[C_x &#43; dx[i]][C_y &#43; dy[i]] &#61; true;}}int k &#61; 0;while (!b[k][0] && k <&#61; B_x){dp[k&#43;&#43;][0] &#61; 1;}int l &#61; 0;while (!b[0][l] && l <&#61; B_y){dp[0][l&#43;&#43;] &#61; 1;}for (int i &#61; 1; i <&#61; B_x; i&#43;&#43;){for (int j &#61; 1; j <&#61; B_y; j&#43;&#43;){if (b[i][j]){dp[i][j] &#61; 0;}else{dp[i][j] &#61; dp[i - 1][j] &#43; dp[i][j - 1];}}}cout << dp[B_x][B_y];
}