```cpp
#include <bits/stdc++.h>
using namespace std;
long long w_res[30][30][30], x, y, z, i, j, k;
#define w_res_init_num 0
long long w(long long a, long long b, long long c) {
printf ("[wsDbg][Line5][clock%d] a=%lld,b=%lld,c=%lld,w_res[a][b][c]=%lld\n", clock(),a,b,c,w_res[a][b][c]);
if (a <= 0 || b <= 0 || c <= 0) return 1;
if (a > 20 || b > 20 || c > 20) return w (20, 20, 20);
if (w_res[a][b][c] != w_res_init_num) return w_res[a][b][c];
if (a < b && b < c) w_res[a][b][c] = w (a, b, c - 1) + w (a, b - 1, c - 1) - w (a, b - 1, c);
else w_res[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 w_res[a][b][c];
}
int main() {
for (i = 0; i < 21; i++) for (j = 0; j < 21; j++) for (k = 0; k < 21; k++) w_res[i][j][k] = w_res_init_num;
while (true) {
scanf ("%lld%lld%lld", &x, &y, &z);
if (x == -1 && y == -1 && z == -1) break;
else printf ("w(%lld, %lld, %lld) = %lld\n", x, y, z, w (x, y, z));
}
return 0;
}
```
by HappyDavid @ 2023-07-16 15:58:02
我看看
by sssscy_free_stdio @ 2023-07-16 15:58:20
while(true)改成while(scanf("%lld%lld%lld",&a,&b,&c)==3)?(我觉得不是)
by sssscy_free_stdio @ 2023-07-16 15:59:41
我知道了
```cpp
if (a < b && b < c) w_res[a][b][c] = w (a, b, c - 1) + w (a, b - 1, c - 1) - w (a, b - 1, c);
else w_res[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);
```
改成:
```cpp
if (a < b && b < c)return w_res[a][b][c] = w (a, b, c - 1) + w (a, b - 1, c - 1) - w (a, b - 1, c);
else return w_res[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 w_res[a][b][c];删掉
by sssscy_free_stdio @ 2023-07-16 16:02:19
@[shenchenyi5](/user/905133) 判abc==-1就不用这个了吧?
by HappyDavid @ 2023-07-16 16:02:34
对
by sssscy_free_stdio @ 2023-07-16 16:05:42
我最后return w_res[a][b][c]了啊……所以我还是重写一遍吧。pwq
~~从上午调到下午,不会我就做不了剩下的计划了吧……~~
by HappyDavid @ 2023-07-16 16:12:33
不用return w_res[a][b][c]
by sssscy_free_stdio @ 2023-07-16 16:13:21
@[HappyDavid](/user/738761)
我帮你改成这样(码风臭),过了
```cpp
#include <bits/stdc++.h>
using namespace std;
long long f[30][30][30], x, y, z, i, j, k;
long long w(long long a, long long b, long long c) {
if(a<=0||b<=0||c<=0){
return 1;
} if(a>20||b>20||c>20){
return w(20,20,20);
}if(f[a][b][c]){
return f[a][b][c];
} if(a<b&&b<c){
return f[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
} else {
return 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);
}
}
int main(){
while(scanf("%lld%lld%lld",&x,&y,&z)==3){
if(x==-1&&y==-1&&z==-1){
break;
} else {
printf("w(%lld, %lld, %lld) = %lld\n",x,y,z,w(x,y,z));
}
}
return 0;
}
by sssscy_free_stdio @ 2023-07-16 16:16:48
@[HappyDavid](/user/738761) 不用重写了,对一遍吧…
by sssscy_free_stdio @ 2023-07-16 16:17:25