rt,本机测试re,交上去MLE,可是看起来绝对不可能RE、mle啊、、、
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=25;
LL a,b,c;
LL f[N][N][N];
LL w(LL x,LL y,LL z){
if(x<=0||y<=0||z<=0){
f[x][y][z]=1;
}
else if(f[x][y][z]){
return f[x][y][z];
}
else if(a<b&&b<c){
f[x][y][z]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
}
else{
f[x][y][z]=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[x][y][z];
}
int main(){
while(true){
memset(f,0,sizeof(f));
f[20][20][20]=1048576;
cin>>a>>b>>c;
if(a==-1&&b==-1&&c==-1) break;
printf("w(%lld, %lld, %lld) = ",a,b,c);
if(a>20||b>20||c>20) a=b=c=20;
printf("%lld\n",w(a,b,c));
}
return 0;
}
求看