全TLE,求调

P1464 Function

aszxqw @ 2024-10-16 13:28:07

#include<bits/stdc++.h> 
#define ll long long
using namespace std;
ll s[50][50][50];
ll w(ll a,ll b,ll c){
    if(a<=0||b<=0||c<=0){
        return 1;
    }else if(a>20||b>20||c>20){
        s[a][b][c]=w(20,20,20);
    }else if(a<b&&b<c){
        s[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    }else{
        s[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 s[a][b][c];
}
int main(){ 
    ll a1,b1,c1;
    while(1){
        cin>>a1>>b1>>c1;
        if(a1==-1&&b1==-1&&c1==-1){
            break;
        }else{
            cout<<"w(1, 1, 1) = "<<w(a1,b1,c1)<<endl;
        }
    }
    return 0;
}

by xhq_5206 @ 2024-10-16 14:12:41

@aszxqw

}else{
  cout << "w(1, 1, 1) = "<<w(a1,b1,c1) <<endl;

你这……


by xhq_5206 @ 2024-10-16 14:13:23

@xhq_5206 sorry没看到


by aszxqw @ 2024-10-16 14:13:24

@xhq_5206 好


上一页 |