老师写的。
2024-12-21 15:27:32
发布于:浙江
2阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int a[25][25];
unsigned long long dp[25][25];
int main() {
int p, q, mx, my;
scanf("%d %d %d %d", &p, &q, &mx, &my);
p++, q++, mx++, my++;
a[mx][my] = 5;
a[mx - 2][my - 1] = 5;
a[mx - 2][my + 1] = 5;
a[mx - 1][my - 2] = 5;
a[mx - 1][my + 2] = 5;
a[mx + 1][my - 2] = 5;
a[mx + 1][my + 2] = 5;
a[mx + 2][my - 1] = 5;
a[mx + 2][my + 1] = 5;
dp[1][1] = 1;
for(int i = 1; i <= p; i++) {
for(int j = 1; j <= q; j++) {
if(a[i][j] == 5) {
continue;
}
dp[i][j] = max(dp[i][j], dp[i - 1][j] + dp[i][j - 1]);
}
}
printf("%llu\n", dp[p][q]);
return 0;
}
这里空空如也
有帮助,赞一个