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



Sample input:
33


Sample output:
2 -1

Submission status: Accepted

Solution code:
x=int(input())

if x==1:
    print(1, 0)
else:
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0 and i<n/2:
                divisors.append(i)
                if i != n // i and n//i<n/2:
                    divisors.append(n//i)

        divisors.sort()
        return divisors
    yakusu=make_divisors(x)
    f=0
    for i in yakusu:
        a=0
        b=a-i
        while(1):
            if (a**5-b**5)==x:
                f=1
                break
            elif (a**5-b**5)>x and b>0:
                break
            else:
                a+=1
                b+=1
        if f==1:
            print(a, b)
            break

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

for i in range(1, 120):
	for j in range(-120, 119):
		if i**5 - j**5 == X:
			print(i, j)
			exit()

Submission status: Accepted

Solution code:
import numpy as np

x = int(input())
k = 0
A = 0
B = 0
for i in range(0, 1000):
    I = i**5
    j = I - x
    J = abs(j)
    k = 0
    while k <= J**(0.2):
        if k**5 == J:
            A = i
            B = k*(np.sign(j))
            break
        k += 1
print(str(A) + ' ' + str(B))

Submission status: Accepted

Solution code:
x=int(input())

a=0
b=0
z=False
if int(x**0.2)**5==x:
  a=int(x**0.2)
else:
  b=1
  while z==False:
    #print(str(b)+"kkk")
    a1=x+b**5
    #print(a1**0.2)
    if (a1**0.2).imag==0 and int(a1**0.2)**5==a1:
      a=int(a1**0.2)
      break
    else:
      a2=x-b**5
      if (a2**0.2).imag==0 and int(a2**0.2)**5==a2:
        a=int(a2**0.2)
        b*=-1
        break
      else:
        b+=1

print(str(a)+" "+str(b))

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    X = int(input())
    
    B = 0
    while B**5 < X:
        B += 1
    B *= -1
    for A in range(10**6):
        while A**5 - B**5 > X:
            B += 1
        if A**5 - B**5 == X:
            print(str(A) + " " + str(B))
            return
    


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = int(input())

my_dict = dict()

for i in range(1000):
    my_dict[i**5] = i

for i in range(-1000, 1000):
    target = x + (i ** 5)
    if (- target) in my_dict:
        print(-my_dict[-target], i)
        exit()
    elif target in my_dict:
        print(my_dict[target], i)
        exit()

Submission status: Accepted

Solution code:
fives = []
m = {}

i = 0 
while i**5 <= 10**15:
    m[i**5] = i
    m[-1 * i**5] = -1*i
    i+=1
x = int(input())

def fun():
    for i in m.keys():
        for j in m.keys():
            if i-j == x:
                print(str(m[i]) + " " + str(m[j]))
                return

fun()

Submission status: Accepted

Solution code:
X = int(input())

N = []
for i in range(123):
    N.append(i**5)

for i in reversed(range(123)):
    for j in reversed(range(i)):
        if X == N[i] - N[j]:
            print(i, j)
            break
        if X == N[i] + N[j]:
            print(i, j * -1)
            break

Submission status: Accepted

Solution code:
import sys

x = int(input())

a_max = pow(10, 4)
b_max = pow(10, 4)

for a in range(a_max):
    for b in range(b_max):
        if pow(a, 5) - pow(b, 5) == x:
            print(a, b)
            sys.exit()
        elif pow(-a, 5) - pow(b, 5) == x:
            print(-a, b)
            sys.exit()
        elif pow(a, 5) - pow(-b, 5) == x:
            print(a, -b)
            sys.exit()
        elif pow(-a, 5) - pow(-b, 5) == x:
            print(-a, -b)
            sys.exit()

Submission status: Accepted

Solution code:
x = int(input())

if x==1:
    print(0,-1);exit()

num_li = [i**5 for i in range(1,1000)]

for i in range(1000):
    a = num_li[i]
    if x-a in num_li:
        b = num_li.index(x-a)+1
        a = -(num_li.index(a)+1)
        break
    if x+a in num_li:
        b = num_li.index(x+a)+1
        a = num_li.index(a)+1
        break

print(b,a)

Submission status: Accepted

Solution code:
x = int(input())
sign = ((1,1),(1,-1),(-1,1),(-1,-1))
isloop=True
for a in range(10**3):
    if(isloop==False):
        break
    for b in range(10**3):
        if(isloop==False):
            break
        for s1,s2 in sign:
            if(isloop==False):
                break
            a1 = s1*a
            b1 = s2*b
            if((a1**5)==(x+b1**5)):
                print(a1,b1)
                isloop=False
                break

Submission status: Accepted

Solution code:
import math
x = int(input())

for i in range(-1000,1000):
  for j in range(-1000,1000):
    X = (i-j)*(i**4 + i**3*j + i**2*j**2 + i*j**3 + j**4)
    if X==x:
      print(i,j)
      exit()

Submission status: Accepted

Solution code:
x = int(input())
d = [[0 for i in range(500)] for j in range(500)]
e = [[0 for i in range(500)] for j in range(500)]
f = [[0 for i in range(500)] for j in range(500)]
for i in range(500):
    d[0][i] = i**5
    d[i][0] = i**5
for i in range(1,500):
    for j in range(1,500):
        d[i][j] = d[0][j]-d[i][0]
        e[i][j] = d[0][j]+d[i][0]
for m in range(500):
    if x in d[m]:
        print(d[m].index(x),m)
        break
    elif x in e[m]:
        print(e[m].index(x),-m)
        break

Submission status: Accepted

Solution code:
import numpy as np
X = int(input())

t = np.arange(0, 2000001, 1)
t = t**5
S = set(t)

for B in range(0,200001,1):
    if X+B**5 in S:
        print("%d %d"%((X+B**5)**0.2, B))
        break
    if X-B**5 in S:
        print("%d %d"%((X-B**5)**0.2, -B))
        break

Submission status: Accepted

Solution code:
#coding: utf-8

import sys

X = int(input())

powers = {}
def powered(i):
    if i in powers:
        return powers[i]
    powered = pow(i, 5)
    powers[i] = powered
    return powered

for a in range(1000, 0, -1):
    for b in range(0, 1000):
        poweredA = powered(a)
        poweredB = powered(b)
        if poweredA - poweredB == X:
            print(a, b)
            sys.exit()
        elif poweredA + poweredB == X:
            print(a, -b)
            sys.exit()

Submission status: Accepted

Solution code:
X = int(input())

for i in range(2,10**5):
    if i ** 5 - (i-1)**5 == X:
        print(i,i-1);exit()

for x in range(-200,200):
    for y in range(-200,200):
        if x** 5 - y ** 5 == X:
            print(x,y);exit()

Submission status: Accepted

Solution code:
import math

x = int(input())

l = math.floor(math.log(abs(x), 5)) + 1000

s = [i**5 for i in range(l)]

a, b = [0,0]

for i in range(l):
    for j in range(l):
        if s[i] +s[j] == x:
            a, b = i, -j
            break
        elif s[i] - s[j] == x:
            a, b = i, j
            break

print(str(a) + " " + str(b))

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    for A in range(-1000, 1000):
        for B in range(-1000, 1000):
            if(A**5 - B**5 == X):
                print(A, B)
                exit(0)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = int(input())
a = 0
b = 0
while a ** 5 - b ** 5 != x and a ** 5 + b ** 5 != x:
    B = a ** 5 - x
    b = int(abs(B ** (1/5)))
    if a ** 5 - b ** 5 == x or a ** 5 + b ** 5 == x:
        break

    a += 1

if a ** 5 - b ** 5 == x:
    print(a, b)
else:
    print(a, -1 * b)

Submission status: Accepted

Solution code:
from decimal import Decimal

X=Decimal(input())
ansa=0
ansb=0
# for b in range(1000):
#     a5 = Decimal(b**5) + X
#     sig = False
#     if a5 < 0:
#         sig = True
#         a5 = abs(a5)
#     a1 = pow(a5,Decimal('0.2'))

#     if sig:
#         a1 *= -1

#     if a1 == int(a1):
#         ansa=int(a1)
#         ansb=b
#         break
# if ansa >0 or ansb>0:
#     print(ansa,ansb)
#     exit()

for a in range(-1000,1000):
    b5 = Decimal(a**5) - X
    sig = False
    if a==100:
        print()
    if b5 < 0:
        sig = True
        b5 = abs(b5)
    b1 = pow(b5,Decimal('0.2'))

    if sig:
        b1 *= -1

    if b1 == int(b1):
        ansa=a
        ansb=int(b1)
        break
print(ansa,ansb)

Submission status: Accepted

Solution code:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _i(): return int(sys.stdin.readline().strip())


def main():
    x = _i()
    sq = [i**5 for i in range(120)]
    for i in range(1, 120):
        i5 = sq[i]
        for j in range(-i, i):
            j5 = sq[j] if j >= 0 else -sq[-j]
            if i5-j5 == x:
                return f"{i} {j}"


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
X = int(input())
Y = [i**5 for i in range(0, 501)]
for i in range(0, 501):
    for j in range(0, 501):
        if (Y[i]-Y[j] == X):
            print('{0} {1}'.format(i, j))
            exit(0)
        if (Y[i]+Y[j] == X):
            print('{0} {1}'.format(i, -j))
            exit(0)

Submission status: Accepted

Solution code:
import sys
x = int(input())

for i in range(10000):
  a = pow(i, 5)
  for j in range(10000):
    b = pow(j, 5)
    if a-b == x:
      print(i, j)
      sys.exit()
    elif a+b == x:
      print(i, -j)
      sys.exit()

Submission status: Accepted

Solution code:
#Ns,Ms,=input().split()
#N=int(Ns)
#M=int(Ms)
#H=list(map(int,input().split()))
#A=[]
#B=[]
#ans_arr=[]
flag=True
A=0
B=0
Ax=0
Bx=0
X=int(input())
while flag:
    for B in range(0,A+1):
        if X== (pow(A,5)-pow(B,5)):
            if flag==True:
               Bx=B
               Ax=A
            flag=False
        elif X== (pow(A,5)+pow(B,5)):
            if flag==True:
               Bx=-B
               Ax=A
            flag=False
    A+=1
print(str(Ax)+" "+str(Bx))

Submission status: Accepted

Solution code:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math as mt
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
x = int(input())
i = 0
se = set()
d = {}
while(True):
    num = i ** 5
    if num > 1e18 :
        break
    d[num] = i
    se.add(num)
    i += 1
# print(se)
for i in se:
    y = i + x
    if y in se:
        # print("s")
        a = max(d[i], d[y]) 
        b = min(d[i], d[y])
        print(a, b)
        break
    y = abs(i-x)
    if y in se:
        # a = max(d[i], d[y]) 
        # b = min(d[i], d[y])
        print(d[i], -d[y])
        break

# #########################################################################################
'''
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
'''

Submission status: Accepted

Solution code:
N = int(input())

i = -1
lst = []
k = 1
while k == 1:
    i += 1
    j = i**5
    lst.append(j)
    for l, n in enumerate(lst):
        if j - n == N:
            print(i,l)
            k = 0
            break
        if j + n == N:
            print(i,-l)
            k=0
            break

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import zip_longest

def grouper(n, iterable, fillvalue=None):
    "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
    args = [iter(iterable)] * n
    return zip_longest(fillvalue=fillvalue, *args)



def get_divisors(x):
    divisors = []
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            divisors.append(i)
            if i != x // i:
                divisors.append(x//i)

    return divisors

def m_exist(n, m):
    #if (n%5)**4 != m%5:
    #    return -1
    a_max = int(abs(m)**(1/2))
    for a in range(a_max):
        calc = 5 * (a**4 - 2*n*a**3 + 2*(n**2)*a**2 - (n**3)*a  )+ n**4
        if calc == m:
            return a
    return -1

x = int(input())




D_Lis = get_divisors(x)
if len(D_Lis) %2 == 1:
    D_Lis.append(D_Lis[-1])
for n, m in grouper(2, D_Lis):
    a = m_exist(n,m)
    if a == -1:
        pass
    else:
        print(a, a-n)
        break
    a = m_exist(m, n)
    if a == -1:
        pass
    else:
        print(a, a-n)
        break

Submission status: Accepted

Solution code:
import math
x=int(input())

b=0
while True:
    p,m=b, -b
    xp, xm = x+p**5, x+m**5
    flag=False
    for i in range(math.ceil(abs(xp)**0.2)+1):
        if i**5 - p**5 == x:
            ans=[i,p]
            flag=True
            break
        if (-1*i)**5 - p**5 == x:
            ans=[-1*i,p]
            flag=True
            break
    for i in range(math.ceil(abs(xm)**0.2)+1):
        if i**5 - m**5 == x:
            ans=[i,m]
            flag=True
            break
        if (-1*i)**5 - m**5 == x:
            ans=[-1*i,m]
            flag=True
            break
    if flag:
        break
    b+=1

print(" ".join(list(map(str,ans))))

Submission status: Accepted

Solution code:
x=int(input())
ab=[]
for i in range(1000):
    ab.append(i**5)
found=0
for a in ab:
    for b in ab:
        if found==1:
            break
        if a-b==x:
            print(int(a**0.2),int((b**0.2)))
            found=1
        elif a+b==x:
            print(int(a**0.2),int(-(b**0.2)))
            found=1
        else:
            continue

Submission status: Accepted

Solution code:
x = int(input())
for a in range(-200,200):
    for b in range(-200,200):
        if pow(a,5)- pow(b,5)==x:
            print(a,b)
            exit()

Submission status: Accepted

Solution code:
x=int(input())
import math
x5=math.ceil(x**0.2)
#print(x5)
import numpy as np 
while(True):
    for ii in np.arange(x5,-1,-1):
        for jj in range(x5+1):
            #print("a,b",ii,jj)
            if ii**5-jj**5==x:
                print(ii,jj)
                exit()
            if ii**5+jj**5==x:
                print(ii,-jj)
                exit()
    x5*=2

Submission status: Accepted

Solution code:
x = int(input())

q = 0
while abs(x) > q**4:
  q += 1

deta = False
for A in range(-q, q+1):
  if deta:
    break
  for B in range(-q, q+1):
    if A**5 - B**5 == x:
      print(A,B)
      deta = True
      break

Submission status: Accepted

Solution code:
X = int(input())
if X == 0:
    print(0,0)
    exit()
for i in range(0,10000):
    for j in range(0,10000):
        if i!=j and (X % abs(i-j) == 0 or X % abs(i+j) == 0):
            if i**5 - j**5 ==X:
                print(i,j)
                exit()
            if i**5 + j**5 ==X:
                print(i,-j)
                exit()
            if -i**5 + j**5 ==X:
                print(-i,-j)
                exit()
            if - i**5 - j**5 ==X:
                print(-i,j)
                exit()

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

X = I()

P = [pow(i, 5) for i in range(1000000)]

m = False
i = 0
j = 0
for q, a in enumerate(P):
    s1 = bisect.bisect_left(P, a - X)
    s2 = bisect.bisect_left(P, X - a)

    if a - X == P[s1]:
        i = q
        j = s1
        break
    if X - a == P[s2]:
        i = q
        j = s2
        m = True
        break

print(i, end=" ")
print("-" if m else "", end ="")
print(j)

Submission status: Accepted

Solution code:
X = int(input())

a = -1
b = 1
def f(x,y): return x**5-y**5

while f(a, b) != X:
    a += 1
    b = a
    while f(a, b) < X:
        b -= 1
        # print("{}, {}".format(a, b))

print(a, b)

Submission status: Accepted

Solution code:
X = int(input())
fact = [(i,i**5) for i in range(-10**3,10**3)]

for i in range(0,len(fact)):
    for j in range(i+1,len(fact)):
        if abs(fact[i][1] - fact[j][1]) == X:
            A = fact[j][0]
            B = fact[i][0]
            break;
        

print(A,B)

Submission status: Accepted

Solution code:
a_list = [0,1]
b_list = [-1]
X = int(input())
i = 1
b=i
while (True):
    a = b
    b = (i + 1) ** 5
    if b - a > X:
        break
    else:
        i += 1
        a_list.append(b)
        b_list.append(-b)
b_list.reverse()
b_list.extend(a_list)
K=len(b_list)
M=int((K-1)/2)

flag=False
for i in range(K-1) :
    for j in range(i+1,K) :
        if b_list[j]-b_list[i]==X :

            print(str(j-M)+' '+str(i-M))
            flag=True
            break
    if flag :
        break

Submission status: Accepted

Solution code:
x = int(input())
count = 0
for i in range(-1000,1000, 1):
    for j in range(-1000,1000, 1):
        if i**5-j**5 == x:
            print(i,j)
            count=1
            break
    if count == 1:
        break

Submission status: Accepted

Solution code:
x = int(input())
def f(a,b):
    return pow(a,4) + b*pow(a,3) + pow(a*b,2) + a*pow(b,3) + pow(b,4)

def divisor(n):
    tank = []
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            tank.append(i)
            if i!=n//i:
                tank.append(n//i)
    tank.sort()
    return tank

lst = divisor(x)
for y in lst:
    for a in range(10000):
        div = x//y
        
        b = a - y
        if f(a,b) == div:
            print(a, b)
            exit()
            
        b = a + y
        if f(a, b) == (-1)*div:
            print(a,b)
            exit()

Submission status: Accepted

Solution code:
#coding:utf-8

x = int(input())
P = 40000
p = []
b = 0
flag = 0

for i in range(1,P+1):
    if x % i == 0:
        p.append(i)

for i in p:
    a = 0
    while a <= 40000:
        b = a - i
        y = (a ** 5) - (b ** 5)
        if y == x:
            print("{} {}".format(a,b))
            flag = 1
            break
        a += 1
    if flag == 1:
        break

Submission status: Accepted

Solution code:
import sys
X = int(input())
from math import sqrt,floor
cand = []
for i in range(1,floor(sqrt(X))+1):
    #print(i)
    if X%i == 0:
        k = X//i
        #print(i,k)
        for j in range(10000):
            eq = (j-i)**4 + (j-i)**3 * j + (j-i)**2 * j**2 + (j-i) * j**3 + j**4
            #print(j,i,eq)
            if eq == k:
                print(j,j-i)
                sys.exit()

Submission status: Accepted

Solution code:
def resolve():
    X = int(input())
    max_num = 200
    for A in range(max_num):
        for B in range(max_num):
            if X == A**5 - B**5:
                print(A, B)
                return
            elif X == A**5 + B**5:
                print(A, -B)
                return

resolve()

Submission status: Accepted

Solution code:
X=int(input())
import sys
for i in range(-1000,1000):
    for j in range(-1000,1000):
        if i**5-j**5==X:
            print(i,j)
            sys.exit()

Submission status: Accepted

Solution code:
X = int(input())
for i in range(1,120):
    for j in range(-120,120):
        if i**5 - j**5 == X:
            print(i,j)
            exit()

Submission status: Accepted

Solution code:
import sys
x = int(input())
for a in range(10**3):
    for b in range(10**3):
        if a**5 - b**5 == x:
            print(a,b)
            sys.exit()
        elif a**5 + b**5 == x:
            print(a,-b)
            sys.exit()

Submission status: Accepted

Solution code:
import sys
import itertools


x = int(input())
for b in itertools.count():
    for a in itertools.count(b):
        a5b5 = a**5 + b**5
        if a5b5 == x:
            print(a, -b)
            sys.exit(0)
        a5b5 = a**5 - b**5
        if a5b5 == x:
            print(a, b)
            sys.exit(0)
        if x < a5b5:
            break

Submission status: Accepted

Solution code:
X = int(input())

def calculate(X):
    for i in range(1,X+1):
        if X%i == 0:
            a = 0
            while True:
                b=a-i
                f = a**5 - b**5
                if f > X and b>0:
                    break
                if f == X:
                    return([a,b])
                a += 1


ans = calculate(X)
print(ans[0],ans[1])

Submission status: Accepted

Solution code:
x=int(input())
a=[]
for i in range(0,500):
  a.append(i**5)
for i in range(0,len(a)):
  for j in range(0,len(a)):
    if(a[i]-a[j]==x):
      print(i,j)
      break
    elif(a[i]+a[j]==x):
      if(i>j):
        print(i,-j)
      else:
        print(j,-i)
      break
  else:
    continue
  break

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

for A in range(-int(X**(1/3))-1, int(X**(1/3))+1):
	for B in range(-int(X**(1/3)), A):
		if B**5 == A**5-X:
			print(A, B)
			exit()

Submission status: Accepted

Solution code:
x = int(input())

for a in range(-121, 121):
    for b in range(-121, 121):
        if a ** 5 - b ** 5 == x:
            print(a ,b)
            break
    if a ** 5 - b ** 5 == x:
        break

Submission status: Accepted

Solution code:
from sys import exit
from math import sqrt

def divisor(x):
    i = 1
    x_divisor = []
    for i in range(1, int(sqrt(x)) + 1):
        if x % i == 0:
            x_divisor.append(i)
            x_divisor.append(x // i)
    result = set(x_divisor)
    return result

x = int(input())
div = divisor(x)
for k in div:
    if x ==  k ** 5:
        print(str(0), str(-k), sep = " ")
        exit()
    else:
        for a in range(1, int(x ** (1/4)) + 1):
            if x == a ** 5 - (a - k) ** 5:
                print(str(a), str(a - k), sep = " ")
                exit()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple

MAX_X = pow(10, 9)
MAX_SQ5 = 2 * int(pow(MAX_X, 1 / 5))


def solve(nb: int) -> Optional[Tuple[int, int]]:
    all_sq5 = set(pow(x, 5) for x in range(MAX_SQ5 + 1))
    for a in range(MAX_SQ5 + 1):
        a5 = pow(a, 5)
        if nb - a5 in all_sq5:
            return int(pow(nb - a5, 1 / 5)), -a
        if nb + a5 in all_sq5:
            return int(pow(nb + a5, 1 / 5)), a
    return None


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    X = int(input())
    # values = []
    # for _ in range(N):
    #     values.append(input().split())
    result = solve(X)
    print(*result)


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))
    # 6 digits float precision {:.6f} (6 is the default value)
    # print("Case #{}: {:f}".format(testcase + 1, result))


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)

Submission status: Accepted

Solution code:
import math
x = int(input())
i = 0
while True:
  if (i**5 <= x):
    s = (x-i**5)**0.2
    s = math.floor(s*(10**7))/(10**7)
  t = (x+i**5)**0.2
  t = math.floor(t*(10**7))/(10**7)
  if s.is_integer() and i**5 <= x:
    print(int(s),-i)
    break
  elif t.is_integer():
    print(int(t), i)
    break
  i += 1

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans = 0
    for i in range(-200,201):
        if ans:
            break
        else:
            for j in range(-201,200):
                if i**5 - j**5 == n:
                    print(i,j)
                    ans = 1
                    break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X=int(input())
for j in range(int(X**0.5)+2,0,-1):
    if X%j==0:
        for a in range(2*(10**4)):
            b=a-j
            S=j*(a**4+b**4+(a**3)*b+(a**2)*(b**2)+a*(b**3))
            if S==X:
                print(a,b)
                exit(0)

Submission status: Accepted

Solution code:
X=int(input())

for a in range(-1000,1000,1):
  for b in range(-1000, 1000,1):
    if a**5==b**5+X:
      print(a,b)
      exit()

Submission status: Accepted

Solution code:
x=int(input())

a=0
b=0
for i in range(1000):
    a=i
    for j in range(-500,500):
        b=j
        if (a**5)-(b**5)==x:
            break
    else:
        continue
    break

print(a,b)

Submission status: Accepted

Solution code:
x=int(input())
i=0
while True:
    a=(i**5-x)
    if(a<0):
        ans=-(-a)**(1/5)
    else:
        ans=a**(1/5)
    if(int(ans)**5==a):
        print(i,int(ans))
        break
    
    a=(i**5+x)
    if(a<0):
        ans=-(-a)**(1/5)
    else:
        ans=a**(1/5)
    if(int(ans)**5==a):
        print(int(ans),i)
        break
    
    i+=1

Submission status: Accepted

Solution code:
import itertools
import math
X=int(input())
arr=[]
arr2=[]
arr3=[]
for i in range(0,640):
    arr.append(i**5)
    arr.append(-i**5)
l=itertools.combinations_with_replacement(arr,2)
for i in l:
    arr2.append(i[0]-i[1])
    arr3.append([i[0],i[1]])
ans=arr3[arr2.index(X)]
print(int(math.pow(abs(ans[0]), 1/5))*(1 if ans[0]>=0 else -1), int(math.pow(abs(ans[1]), 1/5))*(1 if ans[1]>=0 else -1))

Submission status: Accepted

Solution code:
x = int(input())

def fun(x):

    res = []

    for a in range(-1000, 1000):
        for b in range(-1000, 1000):
            mult = a**5 - b**5
            if mult == x:
                res = a, b
                break
    print(res[0], res[1])

fun(x)

Submission status: Accepted

Solution code:
X = int(input())
for i in range(-500, 500):
    A = pow(i, 5)
    for j in range(-500, 500):
        B = pow(j, 5)
        if A-B == X:
            print(i, j)
            exit(0)

Submission status: Accepted

Solution code:
X = int(input())
a = 0
for i in range(10**3,-10**3,-1):
    for j in range(10**3,-10**3,-1):
        if i**5 - j**5 == X:
            print("{} {}".format(i, j))
            exit()