#2错了求助!!!

P1464 Function

hz_prxxx @ 2024-01-22 21:31:28

附上代码

#include<bits/stdc++.h>
using namespace std;
long long ret[105][105][105]={0};
long long x,y,z;
long long s1[10010],s2[10010],s3[10010],s[10010]; 
long long w(long long a,long long b,long long c){
    if(a<=0||b<=0||c<=0) return 1;
    if(a>20||b>20||c>20) return w(20,20,20);
    long long k;
    if(ret[a][b][c]) return ret[a][b][c];
    if(a<b&&b<c) k=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    else k=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
    ret[a][b][c]=k;
    return k;
}
int main(){
    long long i=0;
    while(true){
        cin>>x>>y>>z;
        if(x!=-1||y!=-1||z!=-1){
            s1[i]=x;
            s2[i]=y;
            s3[i]=z;
            s[i]=w(x,y,z);
            i++;
        }
        else break;
    }
    for(long long j=0;j<i;j++){
        cout<<"w("<<s1[j]<<", "<<s2[j]<<", "<<s3[j]<<") = "<<s[j];
        if(j!=i-1) cout<<endl;
    }
    return 0;
}

by 凌浩祺 @ 2024-01-23 10:33:37

是不是超时了?


by hz_prxxx @ 2024-01-24 15:52:39

@凌浩祺 No!!! 只是错了


by 凌浩祺 @ 2024-01-24 15:53:22

原来如此,是WA吧


by michelle_ming @ 2024-01-24 15:54:43

这道题真的就无语...


by 凌浩祺 @ 2024-03-02 09:41:07

我们已经ac了


by hz_prxxx @ 2024-03-17 17:34:59

@凌浩祺 蟹蟹泥


by 凌浩祺 @ 2024-03-18 14:12:29

You're welcome!


by 凌浩祺 @ 2024-04-13 15:38:00

@ruixi0618
你不会还在研究那道题吧??
精神值得敬佩


by hz_prxxx @ 2024-04-14 13:49:12

@凌浩祺 不想理你


|