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:
import sys
import math
X = int(input())


def f(n):
    return int(math.pow(n, 5))


C = []


lastV = 0

count = 0
while True:
    tmp = f(count)
    C.append(tmp)
    count += 1
    if tmp - lastV > 10 ** 9 + 10:
        break
    lastV = tmp


for j in range(len(C)):
    for i in range(len(C)):
        if C[i] + C[j] == X:
            print(*[i, -j])
            sys.exit(0)
        elif C[i] - C[j] == X:
            print(*[i, j])
            sys.exit(0)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = int(input())

b = 10 ** 3
F5 = defaultdict(int)
for i in range(1, 10 ** 3):
    k = pow(i, 5)
    if X <= k:
        b = min(b, i)
    F5[k] = i

b -= 1
while True:
    x = X - pow(b, 5)
    if F5[x]:
        ans = (F5[x], -b)
        break

    b -= 1

print(ans[0], ans[1])

Submission status: Accepted

Solution code:
X = int(input())
for a in range(10**3):
    for b in range(-10**3-1,10**3+1):
        if a**5 + b**5 == X:
            print(a,-b)
            exit()

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math


NN = 202020
MOD = 10**9+7
# MOD = 998244353
INF = float("inf")

x = int(input())
for a in range(1, 1000):
    if pow(a, 5) - pow(a-1, 5) > x:
        break
    b = a-1
    while pow(a, 5) - pow(b, 5) <= x:
        if pow(a, 5) - pow(b, 5) == x:
            print(a, b)
            exit()
        else:
            b -= 1

Submission status: Accepted

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def check(d1,d2):
    end = int(d2**(1/4))
    for A in range(end+1):
        B = A - d1
        test = A**4 + A**3*B + A**2*B**2 + A*B**3 + B**4
        if test == d2:
            return True, A, B
    return False, 0, 0
    

X = int(input())
div = make_divisors(X)
#print(div)

for d in div:
    f, A, B = check(d, X//d)
    if f:
        print(A, B)
        break

Submission status: Accepted

Solution code:
import sys

def make_divisors(n):
    D=[]
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            D.append(i)
            if i!=n//i:
                D.append(n//i)
    return list(sorted(D))

x=int(input())
D=make_divisors(x)
for d in D:
    #print(d)
    now=-(d//2)
    cnt=0
    while cnt<=10**9:
        #print(now+d,now,cnt)
        cnt=(now+d)**5-now**5
        if cnt==x:
            print(now+d,now)
            sys.exit()
        now+=1

Submission status: Accepted

Solution code:
can=[0]
for i in range(1,151):
    can.append(pow(i,5))
    can.append(-pow(i,5))
can.sort()

x=int(input())

end=False
for i in range(len(can)):
    for q in range(len(can)):
        if can[i]-can[q]==x:
            
            print(i-150,q-150)
            end=True
            break
    if end:
        break
else:
    raise ValueError("xx")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(X: int):
    a = 0
    b = 0
    while True:
        for x in [1, -1]:
            tmp = X + (x * b) ** 5
            if tmp < 0:
                continue
            t = int(tmp ** (1 / 5))
            if t ** 5 == tmp:
                print(t, x * b)
                return
        b += 1
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())

L = []

for i in range(500000):
  t = pow(i, 5)
  L.append(t)
  if t >= X:
    k = i
    break

for i in range(len(L)):
  for j in range(len(L)):
    if L[i] - L[j] == X:
      print(i, j)
      exit()
    if L[i] + L[j] == X:
      print(i, -j)
      exit()

while True:
  t = L[-1]
  if t == X:
    print(k, 0)
    exit()
  for i in range(len(L)):
    if t - L[i] == X:
      print(k, i)
      exit()
    if t + L[i] == X:
      print(k, -i)
      exit()
  k += 1
  L.append(pow(k, 5))

Submission status: Accepted

Solution code:
import sys
x=int(input())
y=int(x**0.5)
for i in range(0,y):
    for j in range(-10**4,i):
        if i**5-j**5==x:
            print(i,j)
            sys.exit()
            break

Submission status: Accepted

Solution code:
X = int(input())

X_MAX = 1000000000

for A in range(1, X_MAX + 1):
    if (A + 1) ** 5 - A ** 5 > X: break

A_MAX = A

for A in range(1, A_MAX + 1):
    l = -A_MAX
    r = A_MAX
    while l < r:
        m = l + (r - l) // 2
        if m ** 5 == A ** 5 - X:
            l = r = m
            break
        elif m ** 5 < A ** 5 - X:
            l = m + 1
        else:
            r = m - 1
    #
    B = l
    if A ** 5 - B ** 5 == X: break

print(A, B)

Submission status: Accepted

Solution code:
X = int(input())



for i in range(-150,151):
    for j in range(-150,151):
        if i ** 5 - j ** 5 == X:
            print("{} {}".format(i,j))
            exit()

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    x = int(input())

    num_list = []
    i = 0
    while True:
        num_list.append(i)
        if (i+1)**5 - i**5 > x:
            break
        i += 1

    L = len(num_list)
    for i in range(L):
        a = num_list[i]
        for j in range(L):
            b = num_list[j]
            if a ** 5 - b ** 5 == x:
                print(a, b)
                exit()
            if a ** 5 - (-b) ** 5 == x:
                print(a, -b)
                exit()
            if b ** 5 - a ** 5 == x:
                print(b, a)
                exit()
            if b ** 5 - (-a) ** 5 == x:
                print(b, -a)
                exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())
A = -1000
B = -1000
ok = False


for i in range(200):
    for j in range(200):
        if i**5 - j**5 == X:
            A = i
            B = j
            ok = True
        elif i**5 + j**5 == X:
            A = i
            B = -j
            ok = True
        if ok:
            break
    if ok:
        break

print(A, B)

Submission status: Accepted

Solution code:
x = int(input())
flg = 0
ans1 = 0
ans2 = 0
for i in range(-200,200):
    for j in range(i,200):
        if j ** 5 + i ** 5 == x:
            flg = 1
            ans1 = j
            ans2 = -i

        elif j ** 5 - i ** 5 == x:
            flg = 1
            ans1 = j
            ans2 = i
        if flg:
            break
    if flg:
        break
print(ans1,ans2)

Submission status: Accepted

Solution code:
x = int(input())
done = False
for i in range(-200, 201):
    for j in range(-200, 201):
        if i**5 - j**5 == x:
            print(i, " ", j)
            done = True
        if done:
            break
    if done:
        break

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
import sys

X = int(input())

for a in range(-10**3, 10**3):
    for b in range(-10**3, 10**3):
        if a**5 - b**5 == X:
            print(a, b)
            sys.exit()

Submission status: Accepted

Solution code:


r=[]
for i in range(230):
    A=i-125
    for j in range(230):
        B=j-125
        r.append((A**5-B**5,A,B))
r.sort()

target=int(input())
lwbd = 0
upbd = len(r)


while lwbd<=upbd:
    middle = lwbd + (upbd-lwbd)//2
    if(r[middle][0]==target):
        break
    elif r[middle][0]>target:
        upbd = middle -1
    else:
        lwbd = middle +1
print(r[middle][1],r[middle][2])

Submission status: Accepted

Solution code:
x = int(input())

for i in range(-500, 501):
	for j in range(-500, 501):
		if i ** 5 - j ** 5 == x:
			print(i, j)
			exit()

Submission status: Accepted

Solution code:
from sys import stdin
X = int(stdin.readline().rstrip())
for a in range(-500,501):
    for b in range(-500,501):
        if a**5 - b**5 == X:
          ans1 = a
          ans2 = b
print(ans1,ans2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
for a in range(10**3):
  for b in range(10**3):
    if a**5-b**5 == X:
      ans = [a, b]
      break
    if a**5+b**5 == X:
      ans = [a, -b]
      break
print(ans[0], ans[1])

Submission status: Accepted

Solution code:
x=int(input())
if x==0:
    print('0 0')
i=0
while True:
    flag=False
    a=pow(i,5)
    r=x-a
    if r<0:
        r*=-1
        flag=True
    j=1
    n=1
    while n<r:
        j+=1
        n=pow(j,5)
    if n==r and not flag:
        print(i,-1*j)
        break
    elif n==r and flag:
        print(i,j)
        break
    else:
        i+=1

Submission status: Accepted

Solution code:
x=int(input())
num=[]
for i in range(10001):
    num.append(i**5)

for j in range(10000):
    for k in range(j+1,10001):
        if num[k]-num[j]==x:
            print(k,j)
            exit()
        elif num[k]+num[j]==x:
            print(k,-1*j)
            exit()

Submission status: Accepted

Solution code:
n = int(input())
arr = []
for i in range(1,int(pow(n,1/2))+1):
  if n % i == 0:
    arr.append(i)
res = []
for i in range(len(arr)):
  for j in range(-arr[i]-1,int(pow(n,1/2)+1)):
    if (j + arr[i])**5 - j**5 == n:
      res = [j+arr[i],j]
      break
print(*res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
x = int(input())
for b in range(-(10 ** 4), 10 ** 4):
    ok = 0
    ng = 10 ** 6
    while ng - ok > 1:
        m = (ok + ng) // 2
        if m ** 5 - b ** 5 <= x:
            ok = m
        else:
            ng = m
    a = ok
    if a ** 5 - b ** 5 == x:
        print(a, b)
        exit()

Submission status: Accepted

Solution code:
X = int(input())
M = 10 ** 10
# M = 3
for i in range(1, M):
    A = i ** 5
    ok = 10 ** 5
    ng = -(10 ** 5)
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if A - mid ** 5 <= X:
            ok = mid
        else:
            ng = mid
    if A - ok ** 5 == X:
        print(i, ok)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
X = int(input())

Y = 1 # A-B
flg = 0

while flg==0:
  if X%Y==0 and (Y**4-X//Y)%5==0:
    Z1 = Y*Y
    Z0 = (Y**4-X//Y)//5
    A = 1
    B = A-Y
    while True:
      if (A*B)**2+Z1*A*B == -Z0:
        print(A,B)
        flg = 1
        break
      elif B>0 and (A*B)**2+Z1*A*B > -Z0:
        break
      A += 1
      B += 1
  Y += 1

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(X: int):

    # 和で表現される場合
    upper = 160
    for a in range(-upper, upper+1):
        for b in range(-upper, upper+1):
            if X == a**5-b**5:
                print(a, b)
                return
    # # 差で表現される場合
    # upper = 120
    # for a in range(upper+1):
    #     for b in range(a, upper+1):
    #         if X == a**5-b**5:
    #             print(a, b)
                # return
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    X = int(input())
    #  B < 119

    for b in range(119):
        a = b+1
        
        while a**5 - b**5 < X:
            a += 1
        
        if a**5 - b**5 == X:
            print(a, b)
            exit()
    
    for b in range(-1, -120, -1):
        a = 0
        
        while a**5 - b**5 < X:
            a += 1
        
        if a**5 - b**5 == X:
            print(a, b)
            exit()


main()
# print(main())

Submission status: Accepted

Solution code:
x = int(input())
def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass 
def cal(a,b):
    return a-b
def cal1(a,b):
    return a**4 + a**3*b+a**2*b**2+a*b**3+b**4


# X  = divisor(x)
# X.sort()
# l = []
# print(len(X))
# print(X)
# for i in x:
k = []
for i in range(-200,200):
    for j in range(-200,200):
        if cal(i,j)*cal1(i,j) == x:
            print(i,j)
            exit()

Submission status: Accepted

Solution code:
X = int(input())
L = [0 for _ in range(201)]
for i in range(201):
    L[i] = i * i * i * i * i
flg = False
for i in range(201):
    for j in range(201):
        if L[i] - L[j] == X:
            print(i, j)
            flg = True
        elif L[i] + L[j] == X:
            print(i, -j)
            flg = True
        if flg:
            break
    if flg:
        break

Submission status: Accepted

Solution code:
x = int(input())

list = []
for i in range(-1000, 1001):
    list.append(i ** 5)


def solve():
    for i in range(1, 2001):
        for j in range(i):
            if list[i] - list[j] == x:
                return [i-1000, j-1000]

ans = solve()
print(*ans)

Submission status: Accepted

Solution code:
x = int(input())
a = [i ** 5 for i in range(120)]

for i in range(120):
    for j in range(i + 1, 120):
        if a[j] - a[i] == x:
            print(j, i)
            break
        elif a[j] + a[i] == x:
            print(j, -i)
            break

Submission status: Accepted

Solution code:
n=int(input())
for i in range(int(pow(n,1/5))+100):
	a=i
	b=-1*(n-pow(a,5))

	c=int(pow(abs(b),1/5))
	if b<0:
		c=-c
	if c*c*c*c*c==b:
		print(a,c)
		exit()

Submission status: Accepted

Solution code:
x = int(input())

fives = [i**5 for i in range(10**5)]

for a5 in fives:
    b5 = abs(a5 - x)
    if b5 in fives:
        idx_a = fives.index(a5)
        idx_b = fives.index(b5)
        if a5 - b5 == x:
            pass
        if a5 + b5 == x:
            idx_b = -idx_b
        ans = [idx_a, idx_b]
        break
print(ans[0], ans[1])

Submission status: Accepted

Solution code:
X = int(input())
A = -1
while True:
    A += 1
    if (A ** 5 - X) >= 0:
        temp_num = ((A ** 5 - X) ** (1/5)) // 1
        plus_minus = 1
    else:
        temp_num = ((X - A ** 5) ** (1/5)) // 1
        plus_minus = -1
    if A ** 5 -  (plus_minus * temp_num) ** 5 == X:
        B = plus_minus * temp_num
        break
    elif A ** 5 - (plus_minus * (temp_num + 1)) ** 5 == X:
        B = plus_minus * (temp_num + 1)
        break
print(A,int(B))

Submission status: Accepted

Solution code:
X=int(input())
dict=[]
for i in range(10000):
    for j in range(10000):
        if i**5-j**5==X:
            print(i,j)
            exit()
        if i**5+j**5==X:
            print(i,-1*j)
            exit()

Submission status: Accepted

Solution code:

def factorize(n):
    ## 素因数分解
    # arr = factorize(20)
    # arr == [[2, 2], [5, 1]]
    
    result = []
    tmp = n
    for k in range(2, int(n ** 0.5) + 1):
        cnt = 0
        while tmp % k == 0:
            cnt += 1
            tmp //= k
        if cnt > 0:
            result.append([k, cnt])
    if tmp != 1:
        result.append([tmp, 1])
    return result

def divisorize(n):
    ## 約数
    # arr = factorize(20)
    # arr == [2, 4, 5, 10, 20]
    f = factorize(n)
    divisors = [1]
    for k in range(len(f)):
        num_divisors = len(divisors)
        for i in range(1, f[k][1] + 1):
            for j in range(num_divisors):
                divisors.append(divisors[j] * f[k][0] ** i)
    return sorted(divisors)

x = int(input())
a = 0
d = divisorize(x)
flg = False
while True:
    for dd in d:
        b = a - dd
#         print(a, dd, b)
        try:
            if a ** 5 - b ** 5 == x:
                flg = True
                break
        except:
            pass
    if flg:
        break
    a += 1
print(a, b)

Submission status: Accepted

Solution code:
x=int(input())
for a in range(101):
    for b in range(101):
        if a**5+b**5==x:
            print(f"{a} {-b}")
            exit(0)
for a in range(201):
    for b in range(201):
        if a**5-b**5==x:
            print(f"{a} {b}")
            exit(0)

Submission status: Accepted

Solution code:
X = int(input())

cands = {}
for i in range(-200, 201):
    cands[i**5] = i

for a in range(1, 201):
    A = a ** 5
    B = A - X
    if B in cands:
        b = cands[B]
        print(a, b)
        quit()

Submission status: Accepted

Solution code:
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
x=int(input())
l=make_divisors(x)
if x==0:
  answer=[0,0]
for i in range(math.ceil(2*pow(x,0.2))):
  for j in l:
    if pow(i,5)-pow(i-j,5)==x:
      answer=[i,i-j]
      break
print(answer[0],answer[1])

Submission status: Accepted

Solution code:
import itertools
x=int(input())
a=list(range(-1000,1000))
l=itertools.permutations(a, 2)
for i in l:
  if i[0]**5-i[1]**5==x:
    print(i[0],i[1])
    break

Submission status: Accepted

Solution code:
x=int(input())

a=[0]*1001

for i in range(1001):
    a[i]=i**5

for i in range(1001):
    for j in range(1001):
        if a[i]-a[j]==x:
            print(i,j)
            exit()
        elif a[i]+a[j]==x:
            if (-1*i)**5-j**5==x:
                print(-1*i,j)
                exit()
            elif i**5-(j*-1)**5==x:
                print(i,-1*j)
                exit()

Submission status: Accepted

Solution code:
import math
x = int(input())
for i in range(-1000,1001):
	for j in range(-1000,1001):
		a5 = pow(i , 5)
		b5 = pow(j, 5)
		if a5 - b5 == x:
			exit(print(i , j))

Submission status: Accepted

Solution code:
x = int(input())

ok = False
for a in range(121):
    for b in range(-120, 121):
        if a**5 - b**5 == x:
            print("%d %d" % (a, b))
            ok = True
        if ok:
            break
    if ok:
        break

Submission status: Accepted

Solution code:
x=int(input())

dic={}



a=set([])
for i in range(1000):
    a.add(i**5)
    dic[i**5]=i
    a.add(-1*i**5)
    dic[-1*i**5]=i*(-1)

#print(dic)

for item1 in a:
    for item2 in a:
        if item1 - item2==x:
            print(dic[item1],dic[item2])
            exit()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7
X = int(input())
for i in range(1000):
    for j in range(-1000,1000):
        #print (i**5 - j**5)
        if i**5 - j**5 == X:
            print (i,j)
            exit()

Submission status: Accepted

Solution code:
#create date: 2020-05-03 21:20

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))



def main():
    x = ni()
    for a in range(-1000,1000):
        for b in range(-1000, 1000):
            if a**5 - b**5 == x:
                print("{} {}".format(a, b))
                quit()


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x=int(input())
dic={}
for i in range(10**5):
  dic[i**5]=i
  dic[(-i)**5]=-i
for i in range(10**5):
    if i**5+x in dic:
      print(dic[i**5+x],i)
      break
    if (-i)**5+x in dic:
      print(dic[(-i)**5+x],-i)
      break

Submission status: Accepted

Solution code:
n=int(input())
A=[i**5 for i in range(10000)]
B=[i**5 for i in range(10000)]

for i in A:
    for j in B:
        if i-j==n:
            print(int(i**(1/5)),int(j**(1/5)))
            exit()
        if i+j==n:
            print(int(i**(1/5)),int(-j**(1/5)))
            exit()

Submission status: Accepted

Solution code:
MAX = 1000


def getAgenerator():
    for i in range(MAX):
        yield i


def getBgenerator():
    for j in range(MAX):
        yield j
        yield j * -1


X = int(input())

for a in getAgenerator():
    for b in getBgenerator():
        if a ** 5 - b ** 5 == X:
            print("{} {}".format(a, b))
            exit()

Submission status: Accepted

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

    #divisors.sort(reverse=True)
    return divisors

d = make_divisors(x)
for i in d:
    for a in range(1, 10000):
        b = a-i
        if a**5-b**5 == x:
            print(a, b)
            exit()

Submission status: Accepted

Solution code:
def get_divisor(n: int) -> list:
    divisor = []
    for i in range(1, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            divisor.append(i)
            if n // i != i:
                divisor.append(n // i)
    # divisor.sort() # if you want sorted divisors
    return divisor


x = int(input())
cand = get_divisor(x)
# print(cand)
for d in cand:
    if d**5 == x:
        print(d, 0)
    elif d**5 < x:
        a = d
        b = 0
        while a**5 - b**5 < x:
            a += 1
            b += 1
        if a**5 - b**5 == x:
            print(a, b)
            break

        a = 0
        b = -d
        while a**5 - b**5 < x:
            a -= 1
            b -= 1
        if a**5 - b**5 == x:
            print(a, b)
            break
    else:
        if d % 2 == 0 and (d // 2)**5 + (d // 2)**5 > x:
            continue
        if d % 2 == 1 and ((d + 1) // 2)**5 + (d // 2)**5 > x:
            continue
        a = d
        b = 0
        while a**5 - b**5 > x:
            a -= 1
            b -= 1
            # print(a, b, a**5 - b**5)
        if a**5 - b**5 == x:
            print(a, b)
            break

        a = 0
        b = -d
        while a**5 - b**5 > x:
            a += 1
            b += 1
        if a**5 - b**5 == x:
            print(a, b)
            break

Submission status: Accepted

Solution code:
X = int(input())

for i in range(1000):
    for j in range(1000):
        if i ** 5 - j ** 5 == X:
            result = [i, j]
        if i ** 5 - (-j) ** 5 == X:
            result = [i, -j]

print(*result)

Submission status: Accepted

Solution code:
X = int(input())
F = [0, 1]
i = 2
while F[-1] - F[-2] <= X:
    F += [i**5]
    i += 1
A, B = -1, -1
flag = False
for i in range(0, len(F)):
    for j in range(0, len(F)):
        if F[i] - F[j] == X:
            flag = True
            A = i
            B = j
            break
        elif F[i] + F[j] == X:
            flag = True
            A = i
            B = -j
            break
    if flag:
        break

print(A, B)

Submission status: Accepted

Solution code:
X = int(input())

FIVES = [x ** 5 for x in range(200)]

for ki,vi in enumerate(FIVES):
    for kj,vj in enumerate(FIVES):
        if vi - vj == X:
            print(ki,kj)
            exit()
        if vj - vi == X:
            print(kj,ki)
            exit()
        if vi + vj == X:
            print(ki,-kj)
            exit()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline

X = int(readline())

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

Submission status: Accepted

Solution code:
#D
import math
X = int(input())

flag = False
for a in range(5000):
    
    for b in range(5000):
        if a**5 + b**5 == X:
            print(a,-b)
            flag = True
            break
            
        elif a**5 - b**5 == X:
            print(a,b)
            flag = True
            break
            
    if flag:
        break

Submission status: Accepted

Solution code:
X=int(input())
n5=[n**5 for n in range(1000)]
for i,a in enumerate(n5):
    for j,b in enumerate(n5):
        if a-b==X: print(i,j); exit()
        elif a+b==X: print(i,-j); exit()
        elif -a-b==X: print(-i,j); exit()
        elif -a+b==X: print(-i,-j); exit()

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
import sys
from math import log2,floor,ceil,sqrt
# import bisect
# from collections import deque

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

n = int(ri())
s  = set([i**5 for i in range(1001)])
f,l = -1,-1
sign = 1
for i in s:
    if n+i in s:
        f = i
        l = n+i
        break
    if n-i in s:
        sign = -1
        f = i
        l = n-i
        break
print(int(pow(l,1/5)),int(sign*pow(f,1/5)))

Submission status: Accepted

Solution code:
x = int(input())

l = []
for i in range(400):
    l.append((i + 1 - 200) ** 5)

for i in range(400):
    for j in range(400):
        if ((i + 1 - 200) ** 5 - (j + 1 - 200) ** 5 == x):
            print ("%s %s" % ((i + 1 - 200), (j + 1 - 200)))
            exit (0)

Submission status: Accepted

Solution code:
x = int(input())
def main():
    for a in range(-1000,1001):
        for b in range(-1000,1001):
            if a**5-b**5==x:
                print("{} {}".format(a,b))
                import sys
                sys.exit()

main()

Submission status: Accepted

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

    divisors.sort()
    return divisors
num = make_divisors(x)
n = len(num)
for i in range(n):
    p = num[i]
    q = x//num[i]
    for b in range(-150,150):
        a = b+p
        if a**4 + (a**3)*b + (a*b)**2 + a*(b**3) + b**4 == q:
            print(a,b)
            break

Submission status: Accepted

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

n = int(input())
flag = 0
a = []

for x in range(201):
    a.append(x ** 5)

for x in range(201):
    for y in range(201):
        if a[x] - a[y] == n:
            print(x, y)
            flag = 1
            break
        if a[x] + a[y] == n:
            print(x, -y)
            flag = 1
            break
        if -a[x] - a[y] == n:
            print(-x, y)
            flag = 1
            break
        if -a[x] + a[y] == n:
            print(-x, -y)
            flag = 1
            break

    if flag == 1:
        break

Submission status: Accepted

Solution code:
import itertools
X = int(input().strip())

data = {}
for v in range(-200, 200):
    data[v] = pow(v, 5)

for a, b in itertools.product(data.items(), data.items()):
    if a[1] - b[1] == X:
        print(a[0], b[0])
        break

Submission status: Accepted

Solution code:
x = int(input())
import sys
# -125<A,B<125

l = list(range(-200, 200))
      

for A in l:
  for B in l:
    if pow(A,5) - pow(B,5) == x:
      print(A,B)
      sys.exit()

Submission status: Accepted

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

for b in range(-2*10**3,2*10**3+1):
  for a in range(-2*10**3,2*10**3+1):
    if a**5-b**5==X:
      print(a,b)
      sys.exit(0)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    x = int(input())
    for a in range(1000):
        for b in range(1000):
            if a**5 - b**5 == x:
                print(a, b)
                exit()
            elif a**5 + b**5 == x:
                print(a, -b)
                exit()
            else:
                continue

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X=int(input())

judge=False

for i in range(-1000,1001):
    for j in range(-1000,1001):
        if pow(i,5)-pow(j,5)==X:
            print(i,j)
            judge=True
            break
    if judge:
        break

Submission status: Accepted

Solution code:
x = int(input())
for i in range(-200,200):
    for j in range(-200,200):
        if i**5-j**5==x:
            print(i,j)
            break
    else:
        continue
    break

Submission status: Accepted

Solution code:
x = int(input())
flag = 0

for i in range(-1000, 1000):
    if flag == 1:
        break
    for j in range(-1000, 1000):
        if x + j ** 5 == i ** 5:
            flag = 1
            print(str(i) + " " + str(j))
            break

Submission status: Accepted

Solution code:
x = int(input())
a=0
b=0

for i in range(1001):
  for j in range(-1000,1001,1):
    if i**5-j**5 ==x:
      a = i
      b = j
      break
print(a,b)