在平面上有一些二维的点阵。
这些点的编号就像二维数组的编号一样,从上到下依次为第 11 至第 �n 行,从左到右依次为第 11 至第 �m 列,每一个点可以用行号和列号来表示。
现在有个人站在第 11 行第 11 列,要走到第 �n 行第 �m 列。只能向右或者向下走。
注意,如果行号和列数都是偶数,不能走入这一格中。
问有多少种方案。
Input
输入一行包含两个整数 �n,�m。
Output
输出一个整数,表示答案。
Sample 1
Inputcopy | Outputcopy |
---|---|
3 4 | 2 |
Hint
1≤�,�≤301≤n,m≤30。
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define int ll
using namespace std;
int n,m;
int dp[39][39];
signed main()
{
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
cin>>n>>m;
dp[1][1]=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(i==1&&j==1) continue;
if(i%2==0&&j%2==0) continue;
dp[i][j]=dp[i-1][j]+dp[i][j-1];
}
}
cout<<dp[n][m]<<'\n';
}