AETHER2010 @ 2024-08-31 22:39:12
问题代码如下,试着用记忆化RE了。
int q[25][25][25]={-1};
long long w(long long a,long long b,long long c){
if(a<=0 || b<=0 || c<=0){
return 1;
}
if(q[a][b][c]!=-1){
return q[a][b][c];
}
if(a>20 || b>20 || c<20){
return w(20,20,20);
}
else if(a<b && b<c){
if(q[a][b][c-1]==-1){
q[a][b][c-1]=w(a,b,c-1);
}
if(q[a][b-1][c-1]==-1){
q[a][b-1][c-1]=w(a,b-1,c-1);
}
if(q[a][b-1][c]==-1){
q[a][b-1][c]=w(a,b-1,c);
}
q[a][b][c] = q[a][b][c-1]+q[a][b-1][c-1]-q[a][b-1][c];
}
else{
if(q[a-1][b][c]==-1){
q[a-1][b][c]=w(a-1,b,c);
}
if(q[a-1][b-1][c]==-1){
q[a-1][b-1][c]=w(a-1,b-1,c);
}
if(q[a-1][b][c-1]==-1){
q[a-1][b][c-1]=w(a-1,b,c-1);
}
if(q[a-1][b-1][c-1]==-1){
q[a-1][b-1][c-1]=w(a-1,b-1,c-1);
}
q[a][b][c] = q[a-1][b][c]+q[a-1][b-1][c]+q[a-1][b-1][c]-q[a-1][b-1][c-1];
}
}
by ZMQ_Ink6556 @ 2024-08-31 22:41:54
@AETHER2010 先 CE 吧