w(x,x,x)=2^x可以AC但如何证明

P1464 Function

HakureiReimu_cjrljpx @ 2023-07-07 17:39:24

if(a==b==c) w(a,b,c)=2^a; 这个式子可以AC但谁能帮忙证明他一下


by max11 @ 2023-07-15 09:57:51

代码君来啦||ヽ( ̄▽ ̄)ノミ|Ю```cpp

include<bits/stdc++.h>

using namespace std; int s[30][30][30]; long long f(long long a,long long b,long long c) { if(a<=0 || b<=0 || c<=0) return 1; else if(a>20 || b>20 || c>20) return f(20,20,20); else if(s[a][b][c]!=0) return s[a][b][c]; else if(a<b && b<c) { s[a][b][c]=f(a,b,c-1)+f(a,b-1,c-1)-f(a,b-1,c); return s[a][b][c]; } else { s[a][b][c]=f(a-1,b,c)+f(a-1,b-1,c)+f(a-1,b,c-1)-f(a-1,b-1,c-1); return s[a][b][c]; } } int main() { long long a,b,c; cin>>a>>b>>c; while(!(a==-1 && b==-1 && c==-1)) { cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<f(a,b,c)<<endl; cin>>a>>b>>c; } return 0; }


by max11 @ 2023-07-15 09:58:40

#include<bits/stdc++.h>
using namespace std;
int s[30][30][30];
long long f(long long a,long long b,long long c)
{
    if(a<=0 || b<=0 || c<=0)
        return 1;
    else
        if(a>20 || b>20 || c>20)
            return f(20,20,20);
        else
            if(s[a][b][c]!=0)
                return s[a][b][c];
            else
                if(a<b && b<c)
                {
                    s[a][b][c]=f(a,b,c-1)+f(a,b-1,c-1)-f(a,b-1,c);
                    return s[a][b][c];
                }
                else
                {
                    s[a][b][c]=f(a-1,b,c)+f(a-1,b-1,c)+f(a-1,b,c-1)-f(a-1,b-1,c-1);
                    return s[a][b][c];
                }
}
int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    while(!(a==-1 && b==-1 && c==-1))
    {
        cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<f(a,b,c)<<endl;
        cin>>a>>b>>c;
    }
    return 0;
}

|