Problem:
Score : 400 points

Problem Statement

Give a pair of integers (A, B) such that A^5-B^5 = X.
It is guaranteed that there exists such a pair for the given integer X.

Constraints

1 \leq X \leq 10^9

X is an integer.

There exists a pair of integers (A, B) satisfying the condition in Problem Statement.

Input

Input is given from Standard Input in the following format:

X

Output

Print A and B, with space in between.
If there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.

A B

Sample Input 1

33

Sample Output 1

2 -1

For A=2 and B=-1, A^5-B^5 = 33.

Sample Input 2

1

Sample Output 2

0 -1

Solution in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

long find_nth_root(double x, ll d)
{
    long low = 0, high = 1;
    while (std::pow(high, d) <= x) {
        low = high;
        high *= 2;
    }
    while (low != high - 1) {
        long step = (high - low) / 2;
        long candidate = low + step;

        double value = std::pow(candidate, d);
        if (value == x) {
            return candidate;
        }
        if (value < x) {
            low = candidate;
            continue;
        }
        high = candidate;
    }
    return low;
}

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble
    ll x;
    cin>>x;
    vector<ll> tmp;
    ll t=-1000;
    ll cc=t-x;
    while(cc<=infl){
        tmp.pb(cc);//see(cc);
        t++;
        if(t>1000)break;
        cc=modi(t,5)-x;
    }
    for(int i=0;i<_sz(tmp);i++){
        cc=tmp[i];
        if(cc<0){
            cc*=-1;
            ll xt=find_nth_root(1.0*cc,5);//see(xt,cc);
            if(cc==modi(xt,5)){
                cout<<-cc+x<<' '<<-xt<<nl;
                break;
            }
            continue;
        }
        ll xt=find_nth_root(1.0*cc,5);
        if(cc==modi(xt,5)){
            cout<<-cc+x<<' '<<-xt<<nl;
            break;
        }
    }
    return 0;
}