```
#include <bits/stdc++.h>
using namespace std;
int a[30][30][30];
long long f(long long x,long long y,long long z)
{
if(x<=0||y<=0||z<=0)
return 1;
if(x>20||y>20||z>20)
{
a[20][20][20]=f(20,20,20);
return a[20][20][20];
}
if(a[x][y][z])
return a[x][y][z];
if(x<y&&y<z)
a[x][y][z]=f(x,y,z-1)+f(x,y-1,z-1)-f(x,y-1,z);
else
a[x][y][z]=f(x-1,y,z)+f(x-1,y-1,z)+f(x-1,y,z-1)-f(x-1,y-1,z-1);
return a[x][y][z];
}
int main()
{
long long n,x,y;
while(cin>>n>>x>>y)
{
if(n==-1&&x==y&&n==x)
return 0;
printf("w(%lld, %lld, %lld) = %lld\n",n,x,y,f(n,x,y));
}
return 0;
}
```
看看我的吧十分简便
by drinktowind @ 2023-08-19 16:20:25
我是如果有值直接返回,这样就不用一大堆判断
by drinktowind @ 2023-08-19 16:21:29
如果有用关注一下谢谢喵
by drinktowind @ 2023-08-19 16:21:52
AC了谢谢大佬
%%%%%%
已关注
by hutaooooooo @ 2023-08-20 09:46:27