就打了个 DP 。
#include <bits/stdc++.h>
#define N 35
using namespace std;
int dp[N][N];
int n,m;
int main(){
scanf("%d %d",&n,&m);
dp[1][0]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(i==1)dp[1][j]=dp[n][j-1]+dp[2][j-1];
else if(i==n)dp[n][j]=dp[1][j-1]+dp[n-1][i-1];
else dp[i][j]=dp[i-1][j-1]+dp[i+1][j-1];
}
}
printf("%d",dp[1][m]);
return 0;
}