孬孬 4TLE 1RE

P1464 Function

Florr_m27 @ 2023-11-19 10:08:45

#include<bits/stdc++.h>
using namespace std;
int a[114514];
long long w(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 w(20,20,20);
    }
    else if(a<b&&b<c){
        return w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    }
    else{
        return w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
    }
}
int main(){
    int c;
    for(int i=1;;i++){
        cin>>a[i];
        if(a[i-2]==(0-1)&&a[i-1]==(0-1)&&a[i]==(0-1)){
            break;
        }
    }
    for(int i=1;;i++){
        if(a[i-2]==(0-1)&&a[i-1]==(0-1)&&a[i]==(0-1)){
            break;
        }
        if(i%3==0){
            c=w(a[i-2],a[i-1],a[i]);
            cout<<"w("<<a[i-2]<<","<<a[i-1]<<","<<a[i]<<")="<<c<<endl; 
        }
    }
    return 0;
}

测试


|