@[mairuisheng](/user/1328579)
```cpp
#include<bits/stdc++.h>
using namespace std;
long long int a,b,c,d[25][25][25];
long long int w(long long int x,long long int y,long long int z){
if(x<=0||y<=0||z<=0) return 1;
else if(x>20||y>20||z>20) return w(20,20,20);
else if(x<y&&y<z){
if(!d[x][y][z-1]) d[x][y][z-1]=w(x,y,z-1);
if(!d[x][y-1][z-1]) d[x][y-1][z-1]=w(x,y-1,z-1);
if(!d[x][y-1][z]) d[x][y-1][z]=w(x,y-1,z);
return d[x][y][z-1]+d[x][y-1][z-1]-d[x][y-1][z];
}
else{
if(!d[x-1][y][z]) d[x-1][y][z]=w(x-1,y,z);
if(!d[x-1][y-1][z]) d[x-1][y-1][z]=w(x-1,y-1,z);
if(!d[x-1][y][z-1]) d[x-1][y][z-1]=w(x-1,y,z-1);
if(!d[x-1][y-1][z-1]) d[x-1][y-1][z-1]=w(x-1,y-1,z-1);
return d[x-1][y][z]+d[x-1][y-1][z]+d[x-1][y][z-1]-d[x-1][y-1][z-1];
}
}
int main(){
while(scanf("%lld%lld%lld",&a,&b,&c)){
if(a==-1&&b==-1&&c==-1) return 0;
printf("w(%lld, %lld, %lld) = ",a,b,c);
printf("%lld\n",w(a,b,c));
}
return 0;
}
```
~~求关~~
by a18981826590 @ 2024-07-10 18:25:22
@[mairuisheng](/user/1328579)
``` cpp
ch[a][b][c]=fun(a,b,c-1)+fun(a,b-1,c-1)-fun(a,b-1,c);
```
第二个 else-if 里面
by yx666 @ 2024-07-10 18:27:53
@[a18981826590](/user/1050072) 能告诉我我错在哪里了吗?
by mairuisheng @ 2024-07-10 18:28:28
@[mairuisheng](/user/1328579)
`ch[a][b][c]=fun(a,b,c-1)+fun(a,b-1,c-1)+fun(a,b-1,c);`
改为
`ch[a][b][c]=fun(a,b,c-1)+fun(a,b-1,c-1)-fun(a,b-1,c);`
+改为-
by a18981826590 @ 2024-07-10 18:30:16
@[yx666](/user/825020) @[a18981826590](/user/1050072) 谢谢两位大佬,问题已解决,已关。
by mairuisheng @ 2024-07-10 18:33:19