没错这是一道DP动态规划题
它的状态转换方程是step[j]=step[j]+step[j-1];
知道它的状态转换方程是什么这题就好做了,上代码
#include<iostream>
using namespace std;
int main()
{
long n,m,a,b,step[21]={0},i,j,x,y;
cin>>n>>m>>a>>b;
step[0]=1;
for(i=0;i<=n;i++)
{
for(j=0;j<=m;j++)
{
x=i-a;
y=j-b;
if(x*x+y*y!=5&&(x||y))
{
if(j>0)
step[j]=step[j]+step[j-1];
}
else
step[j]=0;
}
}
cout<<step[m];
}