@[a2539660209](/user/163319) 你这个方法太复杂了吧!你可以先遍历枚举出马能走到的点,在弄卒
by expnoi @ 2020-09-21 18:28:37
@[a2539660209](/user/163319) 初始化的问题
by JRzyh @ 2020-09-21 18:58:56
@[a2539660209](/user/163319)
```cpp
#include<iostream>
#include<cstring>
using namespace std;
const int jump_x[]={0,2,2,1,1,-1,-1,-2,-2};
const int jump_y[]={0,1,-1,2,-2,2,-2,1,-1};
bool sign[40][40]={0};
long long route[40][40];
int main()
{
int b_x,b_y,horse_x,horse_y;
cin>>b_x>>b_y>>horse_x>>horse_y;
for(int i=0;i<9;i++)
{
if(horse_x-jump_x[i]>=0 && horse_x-jump_x[i]<=b_x && horse_y-jump_y[i]>=0 && horse_y-jump_y[i]<=b_y)
{
sign[horse_x-jump_x[i]][horse_y-jump_y[i]]=1;
}
}
route[0][0]=1;
for(int i=0;i<=b_x;i++)
for(int j=0;j<=b_y;j++)
{
if(i==0 && j==0)continue;
if(sign[i][j]!=1)
{
if(i)route[i][j]+=route[i-1][j];
if(j)route[i][j]+=route[i][j-1];
}
// route[i][j]=route[i][j-1]+route[i-1][j];
else
route[i][j]=0;
}
cout<<route[b_x][b_y];
return 0;
}
```
by Smile_Cindy @ 2020-09-21 19:02:13
谢谢兄弟们,我知道我哪里错了
by a2539660209 @ 2020-09-21 21:34:46
@[hts123456](/user/378346) 谢谢
by a2539660209 @ 2020-09-21 21:35:46
@[Zhaoyuhang2008](/user/242524) 谢谢
by a2539660209 @ 2020-09-21 21:35:59
@[Alpha](/user/87058) 谢谢
by a2539660209 @ 2020-09-21 21:36:16