topic description
There are some two-dimensional lattices on the plane.
The numbering of these points is the same as the numbering of a two-dimensional array. From top to bottom, it is the 1st to nth row, and from left to right is the 1st to mth column. Each point can be identified by row number and column number. express.
Now a person is standing at row 1, column 1, and wants to go to row n, column m. You can only go right or down.
Note that if the row number and the number of columns are both even, you cannot enter this grid.
How many options are there.
input format
Input a line containing two integers n, m.
output format
Output an integer representing the answer.
Input and output samples
enter
3 4
output
2
Instructions/Tips
1≤n,m≤30。
Question G of Group A of the first round of the Lanqiao Cup 2020 provincial competition (question H of Group B).
#include<iostream>
using namespace std;
int main()
{
int dp[33][33]={0};
dp[1][1]=1;
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(i==1&&j==1) continue;
if(i%2||j%2)
{
dp[i][j]=dp[i-1][j]+dp[i][j-1];
}
}
}
cout<<dp[n][m]<<endl;
}