在输出部分加了空格之后还是WA
```cpp
#include<bits/stdc++.h>
using namespace std;
long long n,ra[22][22][22],a,b,c;
int w(long long a,long long b,long long c)
{
if(a<=0||b<=0||c<=0)
{
return 1;
}else
{
if(ra[a][b][c]!=0)
{
return ra[a][b][c];
}
else
{
if(a>20||b>20||c>20)
{
ra[20][20][20]=w(20,20,20);
}
if(a<b&&b<c)
{
ra[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
}
else
{
ra[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 ra[a][b][c];
}
}
}
int main()
{
do{
cin>>a>>b>>c;
if(a!=-1&&b!=-1&&c!=-1)
cout<<"w("<<a<<", "<<b<<", "<<c<<")=";
if(a>20)a=21;
if(b>20)b=21;
if(c>20)c=21;
cout<<w(a,b,c)<<endl;
}while(a!=-1&&b!=-1&&c!=-1);
return 0;
}
by 123456zzr @ 2023-03-12 16:53:05
借鉴一下我的
```
#include<iostream>
#define ll long long
int f[21][21][21];
ll w(ll a,ll b,ll c){
if(a<=0||b<=0||c<=0){
return 1;
}
if(a>20||b>20||c>20){
return w(20,20,20);
}
if(a<b&&b<c){
if(f[a][b][c]) return f[a][b][c];
f[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
return f[a][b][c];
}
if(f[a][b][c]) return f[a][b][c];
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(){
ll a,b,c;
for(;;){
scanf("%lld%lld%lld",&a,&b,&c);
if(a!=-1||b!=-1||c!=-1) printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,w(a,b,c));
else break;
}
return 0;
}
```
by jomy @ 2023-03-12 18:02:08
@[123456zzr](/user/755660)
by jomy @ 2023-03-12 18:03:48
@[jomy2013](/user/846398)
好的谢谢大佬
by 123456zzr @ 2023-03-18 09:26:42
@[123456zzr](/user/755660) 不用谢,很简单
by jomy @ 2023-03-18 13:50:15
@[123456zzr](/user/755660) 这里
(a!=-1&&b!=-1&&c!=-1)
应该为
(a!=-1||b!=-1||c!=-1)
by jomy @ 2023-03-18 14:18:06
还有,不能用do while来做
by jomy @ 2023-03-18 14:21:16