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

N = int(input())

L = [(a, a ** 5) for a in range(-200, 200)]

for a, a5 in L:
    for b, b5 in L:
        if b5 - a5 == N:
            print(b, a)
            sys.exit(0)

Submission status: Accepted

Solution code:
# coding: utf-8

x = int(input())

# 1 <= x <= 10^9
# a^5 - b^5 > 10^9
# n^5 - (n-1)^5 > 10^9 ~ 118
nmax = 119
dic = {}
for a in range(nmax+1):
    for b in range(nmax+1):
        a5 = a**5
        b5 = b**5
        m = a5 - b5
        if m not in dic:
            dic[m] = [a, b]

        n = a5 + b5
        if n not in dic:
            dic[n] = [a, -b]

#print(dic)
#print([dic[key] for key in dic if dic[key][0] < 0 or dic[key][1] < 0])
a,b = dic[x]
print(a, b)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# N, K = [int(x) for x in input().split()]

X = int(input())

li = []

n = -1000

while n**5 < 10**15:
    li.append(n**5)
    n += 1

for ai, a in enumerate(li):
    for bi, b in enumerate(li):
        if a - b == X:
            print(ai-1000, bi-1000)
            exit(0)

Submission status: Accepted

Solution code:

x = int(input())
for i in range(-1000,1000):
    for j in range(-1000,1000):
        if i**5 - j**5 == x:
            print(i,j)
            quit()

Submission status: Accepted

Solution code:
import math


def main():
    X = int(input())

    MAX = 10 ** 9

    for b in range(0, MAX + 1):
        # b = 1,2,3...
        a = math.pow(abs(b ** 5 + X), 1 / 5)
        # print(f'b={b} a={a}')
        # print(f'b={b} a={a}')
        if round(a) ** 5 == abs(b ** 5 + X):
            if b ** 5 + X > 0:
                print(int(a), b)
                return
            else:
                print(-int(a), b)
                return

        # b = -1, -2, -3
        a = math.pow(abs(- b ** 5 + X), 1 / 5)
        # print(f'b={-b} a={a}')
        if round(a) ** 5 == abs(- b ** 5 + X):
            if - b ** 5 + X > 0:
                print(int(a), -b)
                return
            else:
                print(-int(a), -b)
                return

    raise ValueError()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
x=int(input())
for a in range(-3000,3000):
    for b in range(-3000,3000):
        if a**5-b**5==x:
            print("{} {}".format(a,b))
            exit()

Submission status: Accepted

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

a = 0
while a < 1000:
  b = -1000
  while b < 1000:
    if a ** 5 - b ** 5 == x:
      print(a, b)
      sys.exit()
    b += 1
  a += 1

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: 
            print(a, b)
            exit()
        elif a**5 + b**5 == x:
            print(a, -b)
            exit()
print('error')

Submission status: Accepted

Solution code:
import sys
x = int(input())
for i in range(-1000,1001):
  for j in range(-1000,1001):
    if x == i**5-j**5:
      print(f"{i} {j}")
      sys.exit()

Submission status: Accepted

Solution code:
from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

x = int(stdin.readline().rstrip())

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

Submission status: Accepted

Solution code:
from collections import defaultdict


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


if __name__ == '__main__':
    X = int(input())
    divs = make_divisors(abs(X))
    for div in divs:
        for a in range(1, int(X ** .5) + 1):
            b = a - div
            if a ** 5 - b ** 5 == X:
                print(a, b)
                exit()

            b = -a - div
            if (-a) ** 5 - b ** 5 == X:
                print(-a, b)
                exit()

Submission status: Accepted

Solution code:
X = int(input())
tane = [x**5 for x in range(130)]

flag = 0
for i in range(len(tane)):
    for j in range(len(tane)):
        a = tane[i]
        b = tane[j]
        if a - b == X:
            print(i,j)
            flag = 1
            break
        elif -a -b ==X:
            print(-i,j)
            flag = 1
            break
        elif a + b == X:
            print(i,-j)
            flag = 1
            break
        elif -a + b == X:
            print(-i,-j)
            flag = 1
            break
    if flag == 1:
        break

Submission status: Accepted

Solution code:
to_the_5 = [0, 1, 32, 243, 1024, 3125, 7776, 16807, 32768, 59049, 100000, 161051, 248832, 371293, 537824, 759375, 1048576, 1419857, 1889568, 2476099, 3200000, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176, 69343957, 79235168, 90224199, 102400000, 115856201, 130691232, 147008443, 164916224, 184528125, 205962976, 229345007, 254803968, 282475249, 312500000, 345025251, 380204032, 418195493, 459165024, 503284375, 550731776, 601692057, 656356768, 714924299, 777600000, 844596301, 916132832, 992436543, 1073741824, 1160290625, 1252332576, 1350125107, 1453933568, 1564031349, 1680700000, 1804229351, 1934917632, 2073071593, 2219006624L, 2373046875L, 2535525376L, 2706784157L, 2887174368L, 3077056399L, 3276800000L, 3486784401L, 3707398432L, 3939040643L, 4182119424L, 4437053125L, 4704270176L, 4984209207L, 5277319168L, 5584059449L, 5904900000L, 6240321451L, 6590815232L, 6956883693L, 7339040224L, 7737809375L, 8153726976L, 8587340257L, 9039207968L, 9509900499L, 10000000000L, 10510100501L, 11040808032L, 11592740743L, 12166529024L, 12762815625L, 13382255776L, 14025517307L, 14693280768L, 15386239549L, 16105100000L, 16850581551L, 17623416832L, 18424351793L, 19254145824L, 20113571875L, 21003416576L, 21924480357L, 22877577568L, 23863536599L, 24883200000L]

X = int(raw_input())

for i in range(len(to_the_5)):
	for j in range(len(to_the_5)):
		if to_the_5[i] - to_the_5[j]  == X:
			print '{} {}'.format(i, j)
			exit()
		if to_the_5[i] + to_the_5[j] == X:
			print '{} -{}'.format(i, j)
			exit()

Submission status: Accepted

Solution code:
X = int(input())

def nb(b):
    if b == 0:
        return 1
    elif b > 0:
        return -b
    else:
        return -b+1

b = 0

def fac(x):
    if x>=0:
        return x**0.2
    else:
        return -(-x)**0.2

while 1:
   
# for i in range(1):
    # print("b:",b)
    a_est = int(fac(b**5+X))
    if a_est**5-b**5==X:
        a = a_est
        break
    elif (a_est+1)**5-b==X:
        a = a_est+1
        break
    
    # print(a_est)
    b = nb(b)

print(a,b)

Submission status: Accepted

Solution code:
from sys import stdin
x = int(stdin.readline().rstrip())
k = True
a = 0
while k:
    b = a**5 - x
    c = False
    if b < 0:
        b *= (-1)
        c = True
    d = int(b**(1/5))    
    if d ** 5 == b:
        k = False
        break
    a += 1
if c:
    d *= -1
print(a,d)

Submission status: Accepted

Solution code:
x = int(input())
n = int((10**9)**(1/5))
for a in range(10**3):
    for b in range(10**3):
        if a**5 - b**5 == x: 
            print(a, b)
            exit()
        elif a**5 + b**5 == x:
            print(a, -b)
            exit()
print('error')

Submission status: Accepted

Solution code:
x=int(input())
gojo=[]
for i in range(-120,120):
    gojo.append(i**5)
for i in range(len(gojo)-1):
    for j in range(i+1,len(gojo)):
        if x==gojo[j]-gojo[i]:
            ans=[j-120,i-120]
for i in ans:
    print(i,end=" ")

Submission status: Accepted

Solution code:
x = int(input())

ans = []
for i in range(0, x//2+1):
    a = i**5
    diff = x - a

    if diff == 0:
        ans.append(i)
        ans.append(0)
        break

    elif diff < 0:
        j = 0
        while True:
            b = j**5
            if diff*(-1) < b:
                break
            if a-b == x:
                ans.append(i)
                ans.append(j)
                break
            j += 1

    elif diff > 0:
        j = 0
        while True:
            b = j**5
            if diff < b:
                break
            if a+b == x:
                ans.append(i)
                ans.append(j*(-1))
                break
            j += 1

    if len(ans) != 0:
        break

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

Submission status: Accepted

Solution code:
from bisect import bisect_right
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    x = int(readline())

    A = [i**5 for i in range(10**6)]
    for b in A:
        a = x + b
        idx = bisect_right(A, a) - 1
        if A[idx] == a:
            print(int(pow(a, 0.2)), int(pow(b, 0.2)))
            break
        
        a = x - b
        idx = bisect_right(A, a) - 1
        if A[idx] == a:
            print(int(pow(a, 0.2)), -int(pow(b, 0.2)))
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

lut = [i**5 for i in range(200)]

a = 0
b = 0

for a, a5 in enumerate(lut):
    for b, b5 in enumerate(lut):
        if a5 + b5 == X:
            print(a,-b)
            exit()
        elif a5 -b5 == X:
            print(a, b)
            exit()

Submission status: Accepted

Solution code:
import math
def main():
  x = int(input())
  r = range(-1000,1000)
  for i in r:
    for j in r:
      if math.pow(i, 5) - math.pow(j, 5) == x:
        print(str(i) + ' ' + str(j))
        return
main()

Submission status: Accepted

Solution code:
X=int(input())

for A in range(-1000,1000):
    for B in range(-1000,1000):
        if A**5-B**5==X:
            print("{} {}".format(A,B))
            exit(0)

Submission status: Accepted

Solution code:
import itertools

X = int(input())

ansL1 = [i for i in range(130)]
ansL2 = [i * (-1) for i in range(1, 130)]
ansL1.extend(ansL2)

L1 = [pow(i, 5)for i in range(130)]
L2 = [pow((-1)*i, 5)for i in range(1, 130)]
L1.extend(L2)

for v in itertools.combinations(L1, 2):
    if v[0] - v[1] == X:
        for i in range(len(L1)):
            if v[0] == L1[i]:
                ans1 = ansL1[i]
            if v[1] == L1[i]:
                ans2 = ansL1[i]
        print(ans1, ans2)
        exit()

Submission status: Accepted

Solution code:
x=int(input())
for i in range(10**3):
  for j in range(10**3):
    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:
import sys

def main():
    X = int(input())

    num = [-1, 1]
    for i in range(501):
        for j in range(501):
            for k in num:
                for l in num:
                    if((k*i)**5-(j*l)**5 == X):
                        print(i*k, j*l)
                        sys.exit()
main()

Submission status: Accepted

Solution code:
import sys

x = int(input())
b_p = 0
b_m = 0

def div(n):
    divs = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    divs
    divs += list(map(lambda x: x*(-1), divs))
    return divs

divs = div(x)
while True:  
    for i in divs:
        a_p = i + b_p
        a_m = i + b_m
        if a_p ** 5 == x + b_p ** 5:
            print(a_p, b_p)
            sys.exit()
        if a_m ** 5 == x + b_m ** 5:
            print(a_m, b_m)
            sys.exit()
    b_p += 1
    b_m -= 1

Submission status: Accepted

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

for i in range(1000):
    for j in range(1000):
        if i**5 + j**5 ==x:
            print(i,end=" ")
            print(-j)
            sys.exit()

        if i**5 - j**5 ==x:
            print(i,end=" ")
            print(j)
            sys.exit()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    X = INT()

    for i in range(1000):
        for j in range(1000):
            if i**5 - j**5 == X:
                print(i, j)
                sys.exit()
            elif i**5 + j**5 == X:
                print(i, j*(-1))
                sys.exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
X = int(input())
for a in range(-200, 201):
    for b in range(-200, 201):
        if a**5 - b**5 == X:
            print(a, b)
            sys.exit()

Submission status: Accepted

Solution code:
import sys
x = int(input())
a = 1
while True:
    if a ** 5 == x:
        print(a, end = ' ')
        print(0)
        sys.exit()
    for b in range(1, int(abs(x - a ** 5) ** (1/5)) + 1):
        if abs(a ** 5 - x) == b ** 5:
            if a ** 5 - x > 0:
                print(a, end = ' ')
                print(b)
                sys.exit()
            else:
                print(a, end = ' ')
                print(-b)
                sys.exit()
    a += 1

Submission status: Accepted

Solution code:
x=int(input())
aa=0
ab=0
for a in range (-200,200):
    for b in range (-200,200):
        if a**5-b**5==x:
            aa=a
            ab=b
print(aa,ab)

Submission status: Accepted

Solution code:
X = int(input())
#X = (24**5)-(15**5)

a = [int( i/2)*((-1)**i) for i in range(1, 1000)]
b = [int( i/2)*((-1)**i) for i in range(1, 1000)]

#a = [24]
#b = [15]
"""
* Aが正ならBは負または、Aより小さい正
* Aが負ならBは負
* X/(a+b)は、1以上の整数
"""

find = False
if X == 0:
  print(0)
else:  
  for a_ in a:
    for b_ in b:

      if a_ + b_ == 0:
        continue
      if a_ >= 0:
        if b_ >= 0 and b_ > a_:
          continue
      if a_ < 0:
        if b_ >= 0:
          continue
      """
      if X%(a_+b_) != 0:
        print("hoge")
        continue
      """
      if (a_**5) - (b_**5) == X:
        print(f"{a_} {b_}")
        find = True
        break
    if find:
      break

Submission status: Accepted

Solution code:
from math import sqrt
x = int(input())
def f(x):
  h = int(sqrt(x))
  for i in range(1,h+1):    
    if x%i == 0:
      
      m = x//i      
      for a in range(0,1000):        
        b = a-i        
        if a**4 + (a**3)*b + (a**2)*(b**2) + a*b**3 + b**4 ==m:
          return a,b
      
print(*f(x))

Submission status: Accepted

Solution code:
X = int(input())

A = 0
B = 0

f = 0

for i in range(400):
    A = -200 + i
    
    if f == 1:
        break
    
    for j in range(400):
        B = -200 + j
        n = A**5 - B**5
        
        if n == X:
            print(A, end=' ')
            print(B)
            f = 1
            break

Submission status: Accepted

Solution code:
X = int(input())

if X == 1:
    print(0, -1)
    exit()

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

def solve(num, X):
    a = 1
    for i in range(1, X+1):
        if (i * 100) ** 5 - (i * 100 - num) ** 5 >= X:
            break
    max_a = 100 * i
    a = max_a - 99
    while a <= max_a:
        if (a) ** 5 - (a -num) ** 5 == X:
            return True, a, a - num
        a += 1
    return False, 0, 0

arr = make_divisors(abs(X))
for num in arr:
    if (num - X) % 5:
        continue
    flag, a, b = solve(num , X)
    if flag:
        print(a, b)
        exit()
    #flag, a, b = solve(-num , X)
    #if flag:
    #    print(a, b)
    #    exit()

Submission status: Accepted

Solution code:
def main():
    x = int(input())
    L = 500
    lst = [pow(i, 5) for i in range(-L, L+1)]

    for a in range(2*L + 1)[::-1]:
        for b in range(2*L + 1)[::-1]:
            val = lst[a] - lst[b]
            if val == x:
                ansa = a
                ansb = b
                break
    print(ansa-L, ansb-L)
main()

Submission status: Accepted

Solution code:
import sys

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

lis = make_divisors(X)

for i in range(len(lis)):
    A = 0
    B = 0
    dis = lis[i]
    for i in range(-2000,200):
        A = i
        B = A - dis
        if A ** 5 - B ** 5 == X:
            print(A, B)
            sys.exit()
        else:
            continue

Submission status: Accepted

Solution code:
#N, M = list(map(int, input().strip().split()))
X = int(input())

start = -200
end = 201

for i in range(start, end):
  for j in range(start, end):
    if i**5 - j**5 == X:
      A, B = i, j
      break
print(A, B)

Submission status: Accepted

Solution code:
D = {}
k = 130
x = int(input())
for i in range(-k, k+1):
    D[i] = i**5
for i in range(-k, k+1):
    for j in range(-k, k+1):
        if D[i]-D[j] == x:
            print(i,j)
            exit()

Submission status: Accepted

Solution code:
# input
X = int( input() )
maxA = 1000
pow5 = list()
for aa in range(maxA):
    pow5.append( aa**5 )
    
# calc    
ans = False
for ii in range(maxA):  
    if( ans==False ):
        X1 = X - pow5[ii]
        X2 = X + pow5[ii]
        if( X1 in pow5 ):
            b = - ii
            a = pow5.index( X1 )
            ans = True
        
    if( ans==False ):
        if( X2 in pow5 ):
            b = ii
            a = pow5.index( X2 )
            ans = True

# out
if(ans):
    print( str(a)+' '+str(b) )

Submission status: Accepted

Solution code:
x = int(input())
kouho = []
for i in range(300):
    kouho.append([i**5,i])
    kouho.append([-i**5,-i])
for i in range(len(kouho)):
    for j in range(len(kouho)):
        if kouho[i][0]-kouho[j][0] == x:
            print(kouho[i][1],kouho[j][1])
            exit()

Submission status: Accepted

Solution code:
x = int(input())
a = 0
b = 0
for i in range(121):
    tmp = (i ** 5 - x)
    flag = True
    #負の値でFalse
    if tmp < 0:
        flag = False
    b_kouho = abs(tmp) **(1/5)
    b_kouho = round(b_kouho) * -1
    if flag:
        b_kouho *= -1
    if i**5 - b_kouho**5 == x:
        a = i
        b = b_kouho
        break
print("{} {}".format(int(a),int(b)))

Submission status: Accepted

Solution code:
X = int(input())
for A in range(1000):
  for B in range(-1000,1000):
    if A ** 5 - B ** 5 == X:
    #if (A ** 4) + B * (A ** 3) + (B ** 2) * (A ** 2) + (B ** 3) * A + (B ** 4) == int(X / (A-B)):
      print(A,B)
      exit(0)

Submission status: Accepted

Solution code:
X = int(input())

N = list(range(-150,150))

M =[]
for i in N:
    m = i**5
    M.append(m)
    
for i in range(0,300):
    Y = M[i]+X
    if Y in M:
        l = M.index(Y)
        print(N[l], N[i])
        break

Submission status: Accepted

Solution code:
def main():
    x=int(input())
    for i in range(-200,200):
        for j in range(-200,200):
            if i**5-j**5==x:
                print(i,j)
                return
    raise Exception()
main()

Submission status: Accepted

Solution code:
l = [0,1,32,243,1024,3125,7776,16807,32768,59049,100000,161051,248832,371293,537824,759375,1048576,1419857,1889568,2476099,3200000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176,69343957,79235168,90224199,102400000,115856201,130691232,147008443,164916224,184528125,205962976,229345007,254803968,282475249,312500000,345025251,380204032,418195493,459165024,503284375,550731776,601692057,656356768,714924299,777600000,844596301,916132832,992436543,1073741824,1160290625,1252332576,1350125107,1453933568,1564031349,1680700000,1804229351,1934917632,2073071593,2219006624,2373046875,2535525376,2706784157,2887174368,3077056399,3276800000,3486784401,3707398432,3939040643,4182119424,4437053125,4704270176,4984209207,5277319168,5584059449,5904900000,6240321451,6590815232,6956883693,7339040224,7737809375,8153726976,8587340257,9039207968,9509900499,10000000000,10510100501,11040808032,11592740743,12166529024,12762815625,13382255776,14025517307,14693280768,15386239549,16105100000,16850581551,17623416832,18424351793,19254145824,20113571875,21003416576,21924480357,22877577568,23863536599,24883200000,25937424601,27027081632,28153056843,29316250624,30517578125,31757969376,33038369407,34359738368,35723051649,37129300000,38579489651,40074642432,41615795893,43204003424,44840334375,46525874176,48261724457,50049003168,51888844699,53782400000,55730836701,57735339232,59797108943,61917364224,64097340625,66338290976,68641485507,71008211968,73439775749,75937500000,78502725751,81136812032,83841135993,86617093024,89466096875,92389579776,95388992557,98465804768,101621504799,104857600000,108175616801,111577100832,115063617043,118636749824,122298103125,126049300576,129891985607,133827821568,137858491849,141985700000,146211169851,150536645632,154963892093,159494694624,164130859375,168874213376,173726604657,178689902368,183765996899,188956800000,194264244901,199690286432,205236901143,210906087424,216699865625,222620278176,228669389707,234849287168,241162079949,247609900000,254194901951,260919263232,267785184193,274794888224,281950621875,289254654976,296709280757,304316815968,312079600999,320000000000]

x = int(input())

flag = False
for i in range(len(l)):
    for j in range(len(l)):
        a = l[i]
        b = l[j]
        if a - b == x:
            print("{} {}".format(i, j))
            
            flag = True
            break
        
        a = l[i] * -1
        b = l[j]
        if a - b == x:
            print("{} {}".format(i * -1, j))
            
            flag = True
            break
        
        a = l[i]
        b = l[j] * -1
        if a - b == x:
            print("{} {}".format(i, j * -1))
            
            flag = True
            break
        
        a = l[i] * -1
        b = l[j] * -1
        if a - b == x:
            print("{} {}".format(i * -1, j * -1))
            
            flag = True
            break
        
    if flag:
        break

Submission status: Accepted

Solution code:

    

def main():
    X = int(input())


    def isOK(A, B):
        eq = A**5 - B**5
        if X <= eq:
            return True
        else:
            False
    
    def bin_search(B):
        # search A
        left = -1
        right = 10 ** 4 * 2

        while right - left > 1:
            mid = left + (right - left) // 2
            if isOK(mid, B):
                right = mid
            else:
                left = mid

        return right
    

    for B in range(-10**4, 10**4+1):
        A = bin_search(B)

        if A**5 - B**5 == X:
            print(A, B)
            exit()


if __name__ == "__main__":
    main()

Submission status: Accepted

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


def get_yakusu(P):
    yakusu = []
    for i in range(1, int(math.sqrt(P))+1):
        if P % i == 0:
            yakusu.append(i)
            if i != int(P / i):
                yakusu.append(int(P / i))
    return yakusu


X_yakusu = get_yakusu(X)

flag = False
K = max(int(10 ** 1.4), int((10 ** 9 / 5) ** 0.25)) + 2
for A in range(0, K):
    if flag:
        break
    for x in X_yakusu:
        B = A - x
        if A ** 5 - B ** 5 == X:
            print(A, B)
            flag = True
            break

Submission status: Accepted

Solution code:
x = int(input())

import math

for a in range(-int(math.pow(x,1./3.)),int(math.pow(x,1./3.))+1):
    for b in range(-int(math.pow(x,1./3.))+1,int(math.pow(x,1./3.))+1):
        if a!=b:
            if x/(a-b) == a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b:
                print(a,b)
                break
    else:
        continue
    break

Submission status: Accepted

Solution code:
n=int(input())
for i in range(-121,121):
    for j in range(-121,121):
        if i**5 - j**5 == n:
            print(i, j)
            exit(0)

Submission status: Accepted

Solution code:
import sys

x = int(input())
flag = False
a = 0

while True:
    for b in range(-a+1,a):
        if  a ** 5 - b  ** 5 == x:
            print(a,int(b))
            sys.exit()
    a += 1

Submission status: Accepted

Solution code:
X=int(input())

def solve(x):
  for i in range(-120,120):
    for j in range(-120,120):
      if i**5-j**5==X:
        print(i,j)
        return
solve(X)

Submission status: Accepted

Solution code:
import sys

X = int(input())
A = []
for i in range(1, int(X**0.5)+1):
    if X%i == 0:
        A.append([i, X//i])

for i in A:
    for a in range(1, int(X**0.5)+1):
        b = a - i[0]
        if a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4 == i[1]:
            print(a, b)
            sys.exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

X = int(input())

limit = 10 ** 13
check = [0]
now = 1
add = 1
while add < limit:
    add = now ** 5
    minus_add = add * -1
    check.append(add)
    check.append(minus_add)
    now += 1
new_array = sorted(check)
len_new_array = len(new_array)
check_combi = list(itertools.combinations(range(len(new_array)), 2))
for x in check_combi:
    # print(x[0], x[1])
    if new_array[x[0]] - new_array[x[1]] == X:
        print(x[0] - (len_new_array - 1) // 2, x[1] - (len_new_array - 1) // 2)
        break
    if new_array[x[1]] - new_array[x[0]] == X:
        print(x[1] - (len_new_array - 1) // 2, x[0] - (len_new_array - 1) // 2)
        break

Submission status: Accepted

Solution code:
import sys

def resolve():
    x=int(input())
    i=1
    while 1:
        for j in range(i):
            if x==i**5-j**5:
                print(i,j)
                sys.exit()
            elif x==i**5+j**5:
                print(i, -1*j)
                sys.exit()
        i+=1
resolve()

Submission status: Accepted

Solution code:
from math import sqrt,ceil,floor
def mi():return map(int,input().split())
def li():return list(mi())
def ii():return int(input())


x=ii()


for i in range(1000000):
    x3=x-pow(i,5)
    x2=abs(x3)
    x1=x2**(1/5)
    x1=int(x1)
    if(pow(x1,5)==x2):
        if(x3>0):
            x1*=(-1)
        print(i,x1)
        break

Submission status: Accepted

Solution code:
X = int(input())
flag = 0
for A in range(0, 6001):
  if(flag == 1):
    break
  for B in range(-6001, 6001):
    if(flag == 1):
      break
    if(A**5 - B**5 == X):
      print(A, B)
      flag = 1
      break

Submission status: Accepted

Solution code:
x = int(input())

p = 0
while True:
    p += 1
    for i in range(-p,p):
        for j in range(-p,p):
            if i**5 - j**5 == x:
                print (i,j)
                exit ()

Submission status: Accepted

Solution code:
x = int(input())
for a in range(-int(x**0.3), int(x**0.3) + 1):
    for b in range(-int(x**0.3), int(x**0.3) + 1):
        if a**5 - b**5 == x:
            print(a, b)
            break
    else:
        continue
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
flag=False
ansi=0
ansj=0
for i in range(1,65):
    for j in range(-65,1):
        if i**5-j**5==x:
            ansi=i
            ansj=j
            flag=True
            break
    if flag:
        break
if not flag:
    for i in range(1,122):
        for j in range(1,122):
            if i**5-j**5==x:
                ansi=i
                ansj=j
                flag=True
                break
        if flag:
            break
print(str(i)+" "+str(j))

Submission status: Accepted

Solution code:
x = int(input())
c = 0
for a in range(-1000,1000):
	for b in range(-1000,1000):
		if pow(a,5)-pow(b,5) == x:
			print(a,b)
			c += 1
			break
	if c >= 1:
		break

Submission status: Accepted

Solution code:
X=int(input())
a=0
while a>-1:
  c=-1#b=a+c
  while c<0:
    if a**5-(a+c)**5==X:
      print(str(a)+" "+str(a+c))
      exit()
    elif a**5-(a+c)**5>X:
      break
    c-=1
  a+=1

Submission status: Accepted

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

for l in range(1,2*(10**4)):
    a =l
    mod = (a%10-X%10)%10
    for b in range(mod,a+1,10):
        if a**5 - b**5 == X:
            print(a,b)
            sys.exit()
    mod = (X%10-a%10)%10
    for b in range(mod,a+1,10):
        if a**5 + b**5 == X:
            print(a,-b)
            sys.exit()

Submission status: Accepted

Solution code:

def solve():
    X = int(input())
    for i in range(500):
        for j in range(-500,500):
            if i**5 -j**5 == X:
                print(i,j)
                break
        else:
            continue
        break

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
x = int(input(''))

can = []
for a in range(10**3):
    a5 = a**5
    if not a5 in can:
        can.append(a5)

result = []
for a in can:
    for b in can:
        if a - b == x:
            ans = "{} {}".format(int(a**(1/5)),int(b**(1/5)))
            if not ans in result:
                result.append(ans)
        if a + b == x and a > b:
            ans = "{} {}".format(int(a**(1/5)),int(-1 * b**(1/5)))
            if not ans in result:
                result.append(ans)

for r in result:
    print(r)

Submission status: Accepted

Solution code:
from math import floor
from math import ceil
X = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

li = []
for i in range(-150,150):
    li.append((i**5, i))

for i in li:
    for j in li:
        if i[0] - j[0] == x:
            print(i[1], j[1])
            exit()