include iostream using namespace std const int const1 100 const int co

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
using namespace std;
const int const1=100;
const int const2=100;
int n,m;
int dp[const1][const2];
void initial()
{
cin>>n>>m;
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
dp[i][j] = -1;
dp[0][0] = 1;
}
bool good(int i, int j)
{
return (i >= 0) && (j >= 0) && (i < n) && (j < m);
}
int solve(int i, int j)
{
if (good(i, j))
{
if (dp[i][j] == -1)
dp[i][j] = solve(i - 2, j - 1) + solve(i - 2, j + 1) + solve(i - 1, j - 2) + solve(i + 1, j - 2);
} else
return 0;
return dp[i][j];
}
int main()
{
initial();
cout<<solve(n - 1, m - 1);
return 0;
}