#3AC,其它全WA

P1464 Function

underline__jian @ 2021-10-29 19:59:33

#include<bits/stdc++.h>
using namespace std;
long long wc[110][110][110]; //3个参数3个数组 
long long w(long long a,long long b,long long c){
    if(a<=0||b<=0||c<=0) return 1;
    else if(wc[a][b][c]!=0) return wc[a][b][c];
    else if(a>20||b>20||c>20) wc[a][b][c]=w(20,20,20);
    else if(a<b&&b<c) wc[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    else wc[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 wc[a][b][c];
}
signed main(){
    long long a,b,c;
    while(scanf("%lld%lld%lld",&a,&b,&c)==3){ //记忆化搜索 
        if(a!=-1&&b!=-1&&c!=-1) printf("w(%lld, %lld, %lld) = ",a,b,c);
        else  break;
        printf("%lld\n",w(a,b,c));
    }
    return 0;
}

by underline__jian @ 2021-10-29 20:00:05

有dalao看看么?


by Enderich @ 2021-10-29 20:17:49

@include wihle循环里改成:

memset(wc,0,sizeof(wc));
        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",w(a,b,c));

by underline__jian @ 2021-10-29 20:19:45

@憨憨的chengheng 为什么呢

(题解也是这样但我不太理解


by WHH_FZZ @ 2022-08-05 01:23:16

signed main(){
    long long a,b,c;
    while(scanf("%lld%lld%lld",&a,&b,&c)==3){ //记忆化搜索 
        if(a!=-1&&b!=-1&&c!=-1) printf("w(%lld, %lld, %lld) = ",a,b,c);
        else  break;
        printf("%lld\n",w(a,b,c));
    }
    return 0;
}

错在这里...额if里面应该是 or 吧......(写成且了).........


|