2067. 走方格
在平面上有一些二维的点阵。
这些点的编号就像二维数组的编号一样,从上到下依次为第 1 至第 n 行,从左到右依次为第 1 至第 m 列,每一个点可以用行号和列号来表示。
现在有个人站在第 1 行第 1 列,要走到第 n 行第 m 列。
只能向右或者向下走。
注意,如果行号和列数都是偶数,不能走入这一格中。
问有多少种方案。
输入格式
输入一行包含两个整数 n,m。
输出格式
输出一个整数,表示答案。
数据范围
输入样例1:
3 4
输出样例1:
2
输入样例2:
6 6
输出样例2:
0
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 35;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
int dp[N][N];
int main()
{
int n, m;
cin >> n >> m;
dp[1][1] = 1;
for(int i = 1; i <= n; i ++ )
{
for(int j = 1; j <= m; j ++ )
{
//这个(1,1)一定要跳过,不然后面会将dp[1][1]重置为0
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] << endl;
return 0;
}