6 6 3 3
6
这道题呢,dfs做呢可以过三个点,dp做可以ac
这两种方法我都写出来
dfs呢,相对来说好理解,在起点进行遍历,看看有几种方法能到达终点
#include<bits/stdc++.h>
using namespace std;
int m,n;
int a,b;
int flag[25][25];
int dirx_ma[8]={-2,-1,1,2,2,1,-1,-2};
int diry_ma[8]={1,2,2,1,-1,-2,-2,-1};//马的运动数组,因为得避开这些点
int ans=0;
void dfs(int x,int y)
{
if(x==n&&y==m)
{
ans++;
return;
}//有一种结果
else
{
if(x>n||y>m||flag[x][y]==1) return;
else dfs(x+1,y),dfs(x,y+1);//它能向下和向右
}
}
int main()
{
cin>>n>>m>>a>>b;
flag[a][b]=1;//马的地方也