Wa求调

P1464 Function

ny_kuangbowen @ 2024-08-24 17:27:58

#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[25][25][25];
bool v[25][25][25];
int w(int a,int b,int c){
    if(a<=0||b<=0||c<=0){
        return 1;
    }
    if(a>20||b>20||c>20){
        return w(20,20,20);
    }
    if(v[a][b][c]){
        return dp[a][b][c];
    }
    if(a<b&&b<c){
        dp[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    }
    else{
        dp[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);
    }
    v[a][b][c]=true;
    return dp[a][b][c];
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    while(1){
        cin>>a>>b>>c;
        if(a==-1){
            return 0;
        }
    //  w(1, 1, 1) = 2
        cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<w(a,b,c)<<"\n";
    }
    for(int i=1;i<=20;i++){
        for(int j=1;j<=20;j++){
            for(int k=1;k<=20;k++){
                cout<<dp[i][j][k];
            }
        }
    }
    return 0;
}            

by Gwiazda @ 2024-08-27 09:01:58

看看楼上我的题解


by Gwiazda @ 2024-08-27 09:03:25

题解传送门


by Gwiazda @ 2024-08-27 09:05:00

注意主函数里是a,b,c同时为-1才停止输入


|