mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 17:56:28 +00:00
P1002 过河卒
R41202168
This commit is contained in:
parent
f590742cf9
commit
c990d8bb2d
34
problem/P1002/P1002.cpp
Normal file
34
problem/P1002/P1002.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int fx[] = {0, -2, -1, 1, 2, 2, 1, -1, -2};
|
||||
const int fy[] = {0, 1, 2, 2, 1, -1, -2, -2, -1};
|
||||
int bx, by, mx, my;
|
||||
long long f[30][30];
|
||||
bool b[30][30];
|
||||
|
||||
int main() {
|
||||
cin >> bx >> by >> mx >> my;
|
||||
bx += 2;
|
||||
by += 2;
|
||||
mx += 2;
|
||||
my += 2;
|
||||
f[2][2] = 1;
|
||||
b[mx][my] = true;
|
||||
for (int i = 1; i <= 8; i++) {
|
||||
b[mx + fx[i]][my + fy[i]] = true;
|
||||
}
|
||||
for (int i = 2; i <= bx; i++) {
|
||||
for (int j = 2; j <= by; j++) {
|
||||
if (b[i][j]) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
f[i][j] = max(f[i][j], f[i - 1][j] + f[i][j - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << f[bx][by] << endl;
|
||||
return 0;
|
||||
}
|
BIN
problem/P1002/data/P1002_5.in
(Stored with Git LFS)
Normal file
BIN
problem/P1002/data/P1002_5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
problem/P1002/data/P1002_5.out
(Stored with Git LFS)
Normal file
BIN
problem/P1002/data/P1002_5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user