Demo entry 6762980

easy

   

Submitted by 反对法 on Oct 18, 2018 at 10:01
Language: C++. Code size: 660 Bytes.

#include <bits/stdc++.h>
#define llt long long
using namespace std;

int a[]={1,2,3,6};
int b[10];
llt Pow(llt x,int t){
    llt ans=1;
    for(int i=0;i<t;++i)
        ans*=x;
    return ans;
}

long long dfs(int rt,long long cnt){
    if(rt==0) {
//        b[rt]=cnt;
//        for(int i=0;i<4;++i)
//            cout<<b[i]<<" ";
//        cout<<endl;
        return 1;
    }
    llt ans=0;
    for(int i=1;;++i){
        llt tmp=Pow(i,a[rt]);
        if(tmp>=cnt) break;
        //b[rt]=i;
        ans+=dfs(rt-1,cnt-tmp);
    }
    return ans;
}
int main(){
    int n;
    cin>>n;
    cout<<dfs(3,n)<<endl;
    return 0;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).