@[xiaohezi](/user/1269609) ,
```cpp
#include<bits/stdc++.h>
#define int long long
using namespace std;
long long x,y,z,ans[155][155][155];
int w(int a,int b,int c)
{
if(a<=0||b<=0||c<=0)return 1;
if(a>20||b>20||c>20)return w(20,20,20);
if(ans[a][b][c])return ans[a][b][c];
if(a<b&&b<c)ans[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
else ans[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 ans[a][b][c];
}
signed main()
{
while(cin>>x>>y>>z)
{
if(x==-1&&y==-1&&z==-1)break;
cout<<"w("<<x<<", "<<y<<", "<<z<<") = "<<w(x,y,z)<<endl;
}
return 0;
}
```
by goIdie @ 2024-08-13 19:56:38
@[xiaohezi](/user/1269609)
会重复调用,浪费时间,记忆化答案。
by cj180202 @ 2024-08-13 19:57:50
@[cj180202](/user/709361)
懂了,(最近有点忙,没来得及看)
by yiwugougou @ 2024-08-21 21:26:07
@[goIdie](/user/1041965) 已关
@[cj180202](/user/709361) 已关
by yiwugougou @ 2024-08-21 21:26:54
@[goIdie](/user/1041965) 按你的代码打了一遍,结果[这样](https://www.luogu.com.cn/record/174059343)了
by yiwugougou @ 2024-08-21 21:35:42
@[xiaohezi](/user/1269609) ,你那打的是减号吗。。。
by goIdie @ 2024-08-21 21:37:18
服了,图省事复制题目上的代码,结果他更我忘大家来找茬
by yiwugougou @ 2024-08-21 21:54:30
打错字了
by yiwugougou @ 2024-08-21 21:54:53