1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| #include <iostream> #include <cmath> #include <algorithm> #include <cstdio> using namespace std;
int a[25][25]; int dx[] = {-2, -2, -1, -1, 1, 1, 2, 2}; int dy[] = {1, -1, -2, 2, 2, -2, -1, 1}; int sx, sy, ex, ey; long long num[25][25];
int main(){ scanf("%d%d%d%d", &sx, &sy, &ex, &ey); for(int i = 0; i < 8; i++){ int tx = ex + dx[i]; int ty = ey + dy[i]; if(tx >= 0 && tx <= sx && ty >= 0 && ty <= sy) a[tx][ty] = 1; } a[ex][ey] = 1; num[0][0] = 1; for(int i = 0; i <= sx; i++){ for(int j = 0; j <= sy; j++){ if(a[i][j] == 0) { if(i > 0) num[i][j] += num[i-1][j]; if(j > 0) num[i][j] += num[i][j-1]; } } }
printf("%lld\n", num[sx][sy]); return 0; }
|