当`a>25||b>25||c>25`是你就RE了
by zhangboju @ 2020-03-02 21:17:07
@[伦理道德](/user/300098)
by zhangboju @ 2020-03-02 21:17:15
还有`a<0||b<0||c<0`也会RE
by zhangboju @ 2020-03-02 21:30:41
还有
```cpp
else{
r[a][b][c]=f(a,b,c-1)+f(a,b-1,c-1)+f(a-1,b,c-1)-f(a-1,b-1,c-1);
return f(a,b,c-1)+f(a,b-1,c-1)+f(a-1,b,c-1)-f(a-1,b-1,c-1);
}
```
写错了
by zhangboju @ 2020-03-02 21:31:16
还有
```cpp
if(r[a][b][c]!=0){
return r[a][b][c];
}
else if(a<=0||b<=0||c<=0){
r[a][b][c]=1;
return 1;
}
else if(a>20||b>20||c>20){
r[a][b][c]=f(20,20,20);
return f(20,20,20);
}
```
位置有误
by zhangboju @ 2020-03-02 21:31:56
错太多了!
by zhangboju @ 2020-03-02 21:32:08
在你的代码上改进后的AC Code
```cpp
#include<iostream>
#include<cstdio>
using namespace std;
long long int a,b,c;
long long int r[25][25][25];
long long int f(long long int a,long long int b,long long int c){
if(a<=0||b<=0||c<=0){
return 1;
}
else if(a>20||b>20||c>20){
return f(20,20,20);
}
else if(r[a][b][c]!=0){
return r[a][b][c];
}
else if(a<b&&b<c){
r[a][b][c]=f(a,b,c-1)+f(a,b-1,c-1)-f(a,b-1,c);
return f(a,b,c-1)+f(a,b-1,c-1)-f(a,b-1,c);
}
else{
r[a][b][c]=f(a-1,b,c)+f(a-1,b-1,c)+f(a-1,b,c-1)-f(a-1,b-1,c-1);
return f(a-1,b,c)+f(a-1,b-1,c)+f(a-1,b,c-1)-f(a-1,b-1,c-1);
}
}
int main(){
while(1){
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",f(a,b,c));
}
return 0;
}
```
by zhangboju @ 2020-03-02 21:32:40
还有`scanf("%lld%lld%lld",&a,&b,&c)==3;`是什么鬼
by zhangboju @ 2020-03-02 21:33:18
@[zhangboju](/user/231600) 感谢大佬Orz,又帮了我一次
by cmaths @ 2020-03-02 21:57:02