1 条题解

  • 0
    @ 2025-12-27 9:26:14
    #include<iostream>
    using namespace std;
    int f(int x){
        if(x<=0) return 0;
        if(x==1) return 1;
        if(x>1&&x%3==0) return 2*f(x/3)-1;
        if(x>1&&x%3==1) return 3*f((x+2)/3)-1;
        if(x>1&&x%3==2) return 4*f((x+1)/3)-1;
    }
    int main(){
        int n;
        cin>>n;
        cout<<f(n)<<endl;
        return 0;
    }
    
    • 1

    信息

    ID
    108
    时间
    1000ms
    内存
    256MiB
    难度
    5
    标签
    (无)
    递交数
    159
    已通过
    66
    上传者