题目传送门
#include <bits/stdc++.h>
using namespace std;
const int N = 25;
typedef long long LL;
LL f[N][N][N];
LL w(LL a, LL b, LL c) {
//注意判断的顺序,防止数组下标越界出现RE错误
if (a <= 0 || b <= 0 || c <= 0) return 1;
else if (a > 20 || b > 20 || c > 20) return w(20, 20, 20);
else if (f[a][b][c]) return f[a][b][c];
else if (a < b && b < c) f[a][b][c] = w(a, b, c - 1) + w(a, b - 1, c - 1) - w(a, b - 1, c);
else f[a][b][c] = w(a - 1, b, c) + w(a - 1, b - 1, c) + w(a - 1, b, c - 1) - w(a - 1, b - 1, c - 1);
return f[a][b][c];
}
int main() {
LL a, b, c;
while (cin >> a >> b >> c) {
if (a == -1 && b == -1 && c == -1) break;
cout << "w(" << a << ", " << b << ", " << c << ") = ";
cout << w(a, b, c) << endl;
}
return 0;
}