#include <iostream>
#include <unordered_map>
using namespace std;
long long deal(int x,int y);
int hx [] = {0 ,1,-1,2,-2,2,-2,1,-1};
int hy [] = {0,2,2,1,1,-1,-1,-2,-2};
int bx,by,h1,h2;
const int MN = 100;
unordered_map<int,long long > map;
int main()
{
cin >> bx >> by >> h1 >> h2;
for (int t = 0; t < 8;++t)
map.insert({h1+hx[t] + (h2 + hy[t])*MN,0});
map.insert({0,1});
cout << deal(bx,by);
return 0;
}
long long deal(int x,int y)
{
if (map.find(x + y*MN) != map.end())
return map.at(x+y*MN);
long long result;
if (!x) {
result = deal(x, y - 1);
map.insert({x+y*MN,result});
return result;
}
if (!y) {
result = deal(x - 1, y);
map.insert({x+y*MN,result});
return result;
}
result = deal (x-1,y) + deal (x,y-1);
map.insert({x+y*MN,result});
return result;
}
代码如上,感谢各位指正错误