你这个代码写的锅挺多
如果a,b,c中有小于0的,你得先判,否则负下标会RE
```cpp
#include <iostream>
using namespace std;
long long m[110][110][110];
long long w(long long a, long long b, long long c) {
if (a <= 0 || b <= 0 || c <= 0)
return 1;
if (m[a][b][c] != 0)
return m[a][b][c];
else if (a > 20 || b > 20 || c > 20)
return m[a][b][c] = w(20, 20, 20);
else if (a < b and b < c)
return m[a][b][c] = w(a, b, c - 1) + w(a, b - 1, c - 1) - w(a, b - 1, c);
else
return m[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 (1)
{
long long a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
if (a == -1 && b == -1 && c == -1)
break;
printf("w(%lld, %lld, %lld) = ", a, b, c);
if(a > 20)
a = 21;
if(b > 20)
b = 21;
if(c > 20)
c = 21;
printf("%lld\n", w(a, b, c));
}
return 0;
}
```
by Meteor_ @ 2023-09-11 18:12:10
@[IOI_ILJYT](/user/902351)
by Meteor_ @ 2023-09-11 18:12:27
```cpp
#include <bits/stdc++.h>
using namespace std;
long long f[25][25][25];
long long w(long long a,long long b,long long c)
{
if(a<=0||b<=0||c<=0) return 1;
else if(a>20||b>20||c>20) return w(20,20,20);
else if(f[a][b][c]!=0) return f[a][b][c];
else if(a<b&&b<c) f[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
else 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);
return f[a][b][c];
}
int main()
{
long long a,b,c;
while(cin>>a>>b>>c)
{
if(a==-1&&b==-1&&c==-1) break;
cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<w(a,b,c)<<endl;
}
return 0;
}
```
by int_stl @ 2023-09-24 21:49:04