P1464 RE求助

P1464 Function

fangzichang @ 2022-07-19 10:30:54

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;//优先判负数,防越界re
    }
    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;
}

求看


by fangzichang @ 2022-07-19 10:35:57

沃日,xyz<=0的判错了,可是仍然re


by 编码落寞 @ 2022-07-19 10:38:41

@fangzichang 把w函数内abc改为xyz


by fangzichang @ 2022-07-19 10:40:02

@编码落寞 我事zz,谢了


|