通过代码:
#include <bits/stdc++.h> #define LL long long int #define range(_iter, _start, _end) for(LL _iter = _start; _iter <= _end; _iter ++) using namespace std; struct axis { LL x, y; void init(){ scanf("%lld%lld", &x, &y); } } B, C; LL a[50][50], avl[50][50]; const LL dx[] = { -1, -2, -2, -1, 1, 2, 2, 1 }; const LL dy[] = { -2, -1, 1, 2, 2, 1, -1, -2 }; int main() { B.init(); C.init(); avl[C.x][C.y] = 1; range(i, 0, 7) if(C.x + dx[i] >= 0 && C.y + dy[i] >= 0) avl[C.x + dx[i]][C.y + dy[i]] = 1; range(i, 0, B.x) range(j, 0, B.y) if(!avl[i][j]) { if(i == 0 && j == 0) a[i][j] = 1; else if(i == 0) a[i][j] = a[i][j - 1]; else if(j == 0) a[i][j] = a[i - 1][j]; else a[i][j] = a[i - 1][j] + a[i][j - 1]; } printf("%lld", a[B.x][B.y]); return 0; }
1314:【例3.6】过河卒(Noip2002)
最新推荐文章于 2025-02-16 17:41:54 发布