附 AC 提交记录:<https://www.luogu.com.cn/record/166831052>
代码:
```cpp
#include <bits/stdc++.h>
// #pragma GCC optimize(2)
using namespace std;
#define int long long
#define rint register int
#define endl '\n'
#define debug(x) cerr << #x << '=' << x << endl;
int a, b, c;
map <tuple <int, int, int>, int> f;
int dfs(int a, int b, int c)
{
if (f[make_tuple(a, b, c)])
{
return f[make_tuple(a, b, c)];
}
if (a <= 0 || b <= 0 || c <= 0)
{
return f[make_tuple(a, b, c)] = 1;
}
if (a > 20 || b > 20 || c > 20)
{
return dfs(20, 20, 20);
}
if (a < b && b < c)
{
return f[make_tuple(a, b, c)] = dfs(a, b, c - 1)
+ dfs(a, b - 1, c - 1)
- dfs(a, b - 1, c);
}
return f[make_tuple(a, b, c)] = dfs(a - 1, b, c)
+ dfs(a - 1, b - 1, c)
+ dfs(a - 1, b, c - 1)
- dfs(a - 1, b - 1, c - 1);
}
signed main(void)
{
while (true)
{
//难得地用起了scanf
scanf("%lld %lld %lld", &a, &b, &c);
if (!~a && !~b && !~c)
{
break;
}
printf("w(%lld, %lld, %lld) = %lld\n", a, b, c, dfs(a, b, c));
}
return 0;
}
```
by junhaowang @ 2024-07-18 11:27:09