# 555蒟蒻求助o(>﹏<)o

@ETguy 2021-07-09 09:32 回复

#include <bits/stdc++.h>
using namespace std;
unsigned long long s[25][25] = {0};
int n, m, a, b;
bool find(int x, int y){
x--;
y--;
if(x == a && y == b)
return true;
if(x == a+1 && y == b+2)
return true;
if(x == a+2 && y == b+1)
return true;
if(x == a+2 && y == b-1)
return true;
if(x == a+1 && y == b-2)
return true;
if(x == a-1 && y == b-2)
return true;
if(x == a-2 && y == b-1)
return true;
if(x == a-2 && y == b+1)
return true;
if(x == a-1 && y == b+2)
return true;
return false;
}
int main(){
cin >> n >> m >> a >> b;
for(int i = 1; i <= n+1; i++){
for(int j = 1; j <= m+1; j++){
if(i == 1 && j == 1){
s[i][j] = 1;
continue;
}
if(find(i, j))
continue;
else if(find(i-1, j))
s[i][j] = s[i][j-1];
else if(find(i, j-1))
s[i][j] = s[i-1][j];
else
s[i][j] = s[i][j-1]+s[i-1][j];
}
}
cout << s[m+1][n+1];
return 0;
}
@wanggk王冠龛 2021-07-09 11:26 回复 举报

#include<iostream>
using namespace std;
int dx[8]={1,1,2,2,-1,-1,-2,-2};//八个方向行与原点的变化
int dy[8]={2,-2,2,-1,2,-2,1,-1};//八个方向列与原点的变化
bool f[30][30];//标记是否可走,可走为0,不可走为1
int n,m,cx,cy;
void biaoji()
{
f[cx][cy]=1;//原点不可走
for(int i=0;i<8;i++)//枚举八个方向
{
int tx=cx+x[i][0];//新点的行
int ty=cy+x[i][1];//新点的列
if(tx>=0&&tx<=n&&ty>=0&&ty<=m)//若行列都没有超出范围
f[tx][ty]=1;//标记不可走
}
}
int main()
{
cin>>n>>m>>cx>>cy;
biaoji();
//后面就直接把f[i][j]的值拿来用即可

return 0;
}