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
x = int(input())

for a in range(-118,120):
    for b in range(-119,119):
        if a ** 5 - b ** 5 == x:
            print(str(a)+' '+str(b))
            sys.exit(0)

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(a,b)
      exit()

Submission status: Accepted

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

Submission status: Accepted

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

m = math.ceil((x / 2) ** (1 / 5))
M = int(x ** (1 / 5))
for i in range(m, M + 1):
    n = int((x - i ** 5) ** (1 / 5))
    if n ** 5 == x - i ** 5:
        print(str(int(i)) + ' ' + str(int(-n)))
        break

l = M
L = math.ceil((x / 5) ** (1 / 4) + 1)
for i in range(l + 1, L):
    n = int((i ** 5 - x) ** (1 / 5))
    if n ** 5 == i ** 5 - x:
        print(str(int(i)) + ' ' + str(int(n)))
        break

Submission status: Accepted

Solution code:
x = int(input())
a = [pow(i, 5) for i in range(-121, 122)]
flag = 0
for i in range(len(a)):
    for j in range(i+1, len(a)):
        if a[i] - a[j] == x:
            print(i-121, j-121)
            flag = 1
            break
        elif a[j] - a[i] == x:
            print(j-121, i-121)
            flag = 1
            break
    if flag == 1:
        break

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    X = int(input())
    l = [i ** 5 for i in range(120)]
    for i in l:
        for j in l:
            if i + j == X:
                print(int(i ** (1 / 5)), int(-1 * j ** (1 / 5)))
                break
            elif i - j == X:
                print(int(i ** (1 / 5)), int(j ** (1 / 5)))
        else:
            continue
        break


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x = int(input())
for a in range(120):
    for b in range(-120, a):
        if pow(a,5)-pow(b,5)==x:
            print(a,b)
            break
    else:
        continue
    break

Submission status: Accepted

Solution code:
X = int(input())

for A in range(-118, 120):
    for B in range(-119, 119):
        if A**5 - B**5 == X:
            print("{} {}".format(A, B))
            break
    else:
        continue
    break

Submission status: Accepted

Solution code:
from sys import stdin

def ans():
    _in = [_.rstrip() for _ in stdin.readlines()]
    X = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    for A in range(-118,120):
        for B in range(-119,A):
            if A**5-B**5 == X:
                break
        else:
            continue
        break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(A, B)


if __name__ == "__main__":
    #main()
    ans()

Submission status: Accepted

Solution code:


def submit():
    x = int(input())

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


if __name__ == "__main__":
    submit()

Submission status: Accepted

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

    a = -1
    
    while True:
        b1 = 0
        b2 = 0
        while b1 < a:
            
            if (X/(a-b1)).is_integer():
                if int(X/(a-b1)) == a**4 + b1*(a**3) + (a**2)*(b1**2) + a*(b1**3) + b1**4:
                    print("{} {}\n".format(a, b1))
                    return 0

            if (X/(a-b2)).is_integer():
                if int(X/(a-b2)) == a**4 + b2*(a**3) + (a**2)*(b2**2) + a*(b2**3) + b2**4:
                    print("{} {}\n".format(a, b2))
                    return 0

            b1 += 1
            b2 -= 1
            
        a += 1


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def fip(x):
    return x*x*x*x*x

x = int(input())
divisors = []
i = 1
while i*i<=x:
    if x%i == 0:
        divisors.append(i)
        divisors.append(round(x/i))
    i+=1
for d in divisors:
    if fip(d)-fip(0) == x:
        print(d,0)
        break
    end = 1
    while fip(end)-fip(end-d)<=x:
        end*=2
    start = round(end/2)
    if end == 1:
        if fip(1)-fip(1-d) == x:
            print(1,1-d)
            break
    elif fip(end)-fip(end-d)==x:
        print(end,end-d)
        break
    answer = -1
    found = False
    while(start<=end and not found):
        mid = (start+end)//2
        if fip(mid)-fip(mid-d) == x:
            answer = mid
            found = True
        else:
            if fip(mid)-fip(mid-d)>x:
                end = mid-1
            else:
                start = mid+1
    if answer!=-1:
        print(answer,answer-d)
        break
    start = 0
    end = round((x/2)**(1/5))
    found = False
    while(start<=end and not found and start<=d):
        if fip(start)+fip(d-start) == x:
            answer = start
            found = True
        start+=1
    if found == True:
        print(answer,answer-d)
        break

Submission status: Accepted

Solution code:
x=int(input())
j=0
while True:
  j+=1
  for i in range(j+1):
    a=j
    b=j-i
    if pow(a,5)-pow(b,5)==x:
      print(a,b)
      exit(0)
    b*=-1
    if pow(a,5)-pow(b,5)==x:
      print(a,b)
      exit(0)
    b*=-1
    a*=-1
    if pow(a,5)-pow(b,5)==x:
      print(a,b)
      exit(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
for i in range(121):
  for j in range(250):
    if i**5 - (120 -j)**5 == X:
      a = i
      b = 120 - j
print(str(a) + ' ' + str(b))

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
X = int(input())

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

    if flag:
        break

Submission status: Accepted

Solution code:
X=int(input())

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

Submission status: Accepted

Solution code:
X=int(input())

A=0
B=0

while True:
    A=0
    while A**5<=X+B**5:
        if A**5==X+B**5:
            print(A,B)
            exit()
        elif A**5==X-B**5:
            print(A,-1*B)
            exit()
        A+=1
    B+=1

Submission status: Accepted

Solution code:
x = int(input())
a = 0
for i in range(-118,120):
    for j in range(-119,119):
        if(i**5-j**5==x):
            print(i,j)
            a=1
            break
    if a==1:
        break

Submission status: Accepted

Solution code:
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
x = int(input())
a = 0
b = 0
comp = 0
while comp == 0 :
    aa = a**5
    tmp = aa - x
    if tmp < 0:
        b = -(pow(-tmp,1/5))
    elif tmp == 0:
        b = 0
    else:
        b = pow(tmp,1/5)
    b = Decimal(str(b)).quantize(Decimal('0.00000001'), rounding=ROUND_HALF_UP)
    b = float(b)
    if b.is_integer():
        b = int(b)
        comp = 1
    elif a <= 0:
        a = abs(a)+1
    else:
        a = -a
print(a,b)

Submission status: Accepted

Solution code:
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
x = int(input())

a = 0
b = 0
comp = 0
# print('{:.2f}'.format(pow(3125,1/5)))
while comp == 0 :
    aa = a**5
    tmp = aa - x
    if tmp < 0:
        b = -(pow(-tmp,1/5))
        b = Decimal(str(b)).quantize(Decimal('0.00000001'), rounding=ROUND_HALF_UP)
    elif tmp == 0:
        b = 0
    else:
        b = pow(tmp,1/5)
        b = Decimal(str(b)).quantize(Decimal('0.00000001'), rounding=ROUND_HALF_UP)
    b = float(b)
    if b.is_integer():
        b = int(b)
        comp = 1
    else:
        aa = (-a)**5
        tmp = aa - x
        if tmp < 0:
            b = -(pow(-tmp,1/5))
            b = Decimal(str(b)).quantize(Decimal('0.00000001'), rounding=ROUND_HALF_UP)
        elif tmp == 0:
            b = 0
        else:
            b = pow(tmp,1/5)
            b = Decimal(str(b)).quantize(Decimal('0.00000001'), rounding=ROUND_HALF_UP)
        b = float(b)
        if b.is_integer():
            b = int(b)
            a = -a
            comp = 1
        else:
            a += 1
print(a,b)

Submission status: Accepted

Solution code:
X=int(input())
l=[]
for i in range(300):
    a=i**5
    l.append(a)
    l.append(-a)
for j in l:
    for s in l:
        if j-s==X and j!=s:
            ans=[]
            for i in [j,s]:
                aaa=abs(i)**(1/5)
                if i>=0:
                    ans.append(int(aaa))
                else:
                    ans.append(int(-aaa))
            print(*ans)
            exit()

Submission status: Accepted

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

    flag=0
    for A in range(-118,120):
        for B in range(-119,119):
            if pow(A,5)-pow(B,5)==X:
                print("{} {}".format(A,B))
                flag=1
        if flag==1:
            break
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:

from itertools import permutations

def power(base, exp):
  """ Fast power calculation using repeated squaring """
  if exp < 0:
      return 1 / power(base, -exp)
  ans = 1
  while exp:
      if exp & 1:
          ans *= base
      exp >>= 1
      base *= base
  return ans

def parse():
  return int(input())

def main():
  X = parse()

  A = None
  B = None

  # Z = [i for i in range(0, 5)]
  # print(Z)
  # print(list(permutations(range(0, 5), 2)))
  # print(list(permutations(range(0, 5), 2)))
  # exit(0)

  max_val = 1000
  signs = [[1, 1], [-1, 1], [1, -1], [-1, -1]]

  for i in range(0, max_val + 1):
    for j in range(0, max_val + 1):
      for sign in signs:
        # A5 = 
        # print(i * sign[0], j * sign[1])
        if power(i * sign[0], 5) - power(j * sign[1], 5) == X:
          A = i * sign[0]
          B = j * sign[1]
          print(A, B)
          exit(0)
  print(0, 0)

if __name__ == "__main__":
  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(a, b)
            exit()

Submission status: Accepted

Solution code:
x = int(input())
a = 0
if x == 0:
    print(0, 0)
else:
    while a ** 5 - (a - 1) ** 5 <= x:
        a += 1
        b = a
        while a ** 5 - b ** 5 < x:
            b -= 1
            if a ** 5 - b ** 5 == x:
                break
        else:
            continue
        break
    print(a, b)

Submission status: Accepted

Solution code:
x = int(input())

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:
x = int(input())

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

Submission status: Accepted

Solution code:
import sys
INF = 10**9
sys.setrecursionlimit(INF)
import math


def main():
    x, = map(int, open(0).read().split())

    """
    x=a^5-b^5=(a-b)(a^4+a^3b+a^2b^2+ab^3+b^4)
    x//(a-b)=int>0
    a-b>0
    x=O(a^4)
    """

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

    ans = f'{a} {b}'
    print(ans)
    return(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X=int(input())
for a in range(-118,119):
    for b in range(-119,118):
        c=a**5-b**5
        if c == X:
            break
    if c==X:
        break

print(a,b)

Submission status: Accepted

Solution code:
# 解説を参考に作成

def solve():
    X = int(input())
    A, B = 0, 0
    # A と B の差が最も小さい時(A - B = 1)に, ans < 10**9 となるのは
    # -118 <= A <= 119, -119 <= B <= 118 の場合となる.
    # A - B > 1 の場合でも同じ範囲だけ見れば十分となる.
    # A - B < 1 の場合は答えが負になるので, X >= 1 の制約から検討不要.
    for a in range(-118, 119 + 1):
        for b in range(-119, 118 + 1):
            if a ** 5 - b ** 5 == X:
                A, B = a, b
                break
    print(A, B)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
# 解説を参考に作成

def solve():
    X = int(input())
    A, B = 0, 0
    for a in range(-200, 200):
        for b in range(-200, 200):
            if a ** 5 - b ** 5 == X:
                A, B = a, b
                break
    print(A, B)



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys

X = int(input())
for i in range(-130, 131):
    for j in range(-130, 131):
        if i**5 - j**5 == X:
            print(i, j)
            sys.exit()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import sys

x = int(input())

b = 0
ans=(-1,-1)
while True:
    a5 = b**5 + x

    # 判断a是不是整数5次方
    a = b+1
    if a**5>a5:
        break
    while a**5<a5:
        a+=1
    if a**5==a5:
        ans=(a,b)
        break

    b+=1

if ans[0]!=-1:
    print(ans[0],ans[1])
    sys.exit(0)

b=-1
while True:
    a5=b**5+x

    a=b+1
    while a**5<a5:
        a+=1
    if a**5==a5:
        ans=(a,b)
        break

    b-=1

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

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)
            exit()

Submission status: Accepted

Solution code:
import math

X = int(input())
uplim = math.floor((X/5)**(0.25) + 1)
for A in range(uplim+1):
	for B in range(-uplim, uplim+1):
		if A**5 - B**5 == X:
			print(A,B)
			exit()

Submission status: Accepted

Solution code:
x = int(input())
resA = 0
resB = 0
for a in range(500):
  for b in range(-500,500):
    A = a**5
    B = b**5
    N= A-B
    if A-B==x:
      resA = a
      resB = b
      break
    else:
      pass
  if A-B==x:
    break
print(resA,resB)

Submission status: Accepted

Solution code:
X = int(input())
for A in range(-200, 200+1):
  for B in range(-200, 200+1):
    if A*A*A*A*A-B*B*B*B*B == X:
      print(A, B)
      exit()
print(-1)

Submission status: Accepted

Solution code:
x = int(input())
for i in range(240):
    a = -120 + i
    for j in range(240):
        b = -120 + j
        c = a ** 5 - b ** 5
        if c == x:
            ans1 = a
            ans2 = b
            break
print(str(ans1) + " " + str(ans2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def divisor(n):
    ans = []
    sqr = int(math.sqrt(n))
    for x in range(1, sqr+1):
        if n % x == 0:
            ans.append(x)
            y = n//x
            if x != y:
                ans.append(y)
    ans.sort()
    return ans

x = int(input())
div = divisor(x)
flag = False
for i in div:
    if flag:
        break
    a = i // 2
    j = x // i
    b = a - i
    jj = a**4+a**3*b+a**2*b**2+a*b**3+b**4
    #print('a = {0}, b = {1}'.format(a, b))
    #print('i = {0},  j = {1}, jj = {2}'.format(i, j, jj))
    while(jj <= j):
        b = a - i
        jj = a**4+a**3*b+a**2*b**2+a*b**3+b**4
        #print('a = {0}, b = {1}'.format(a, b))
        #print('i = {0}, j = {1}, jj = {2}'.format(i, j, jj))
        if j == jj:
            print('{0} {1}'.format(a, b))
            flag = True
            break
        a += 1

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  x=I()
  for a in range(-500,501):
    for b in range(-500,501):
      if a**5-b**5==x:
        return str(a)+' '+str(b)

# main()
print(main())

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def f(a, b):
    return pow(a, 5) - pow(b, 5)
 
def main():
    x = int(readline())    
    for i  in range(-1000, 1001):
        for j in range(-1000, 1001):
            if i**5 - j**5 == x:
                print(i, j)
                return
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = int(input())
for i in range(-120, 121):
    for j in range(-120, 120):
        if i ** 5 - j ** 5 == x:
            print(f'{i} {j}')
            break
    else:
        continue
    break

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


def resolve():

    # 問題の前提：1 <= X <= 10億。
    x = int(input())

    # 最下部で行った検証を基に処理を書く。
    # Aが取りうる範囲は・・0~119
    for a in range(120):
        # Bが取りうる範囲は・・-118~119
        for b in range(-118, 120, 1):
            if pow(a, 5) - pow(b, 5) is x:
                print('{} {}'.format(a, b))
                return


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """33"""
        output = """2 -1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1"""
        output = """0 -1"""
        self.assertIO(input, output)

if __name__ == "__main__":

    # unittest.main()
    resolve()

    # (調査)
    # A+Bがいくら以上になる場合、10億を超えるか。(結果が10億を超えるパターンは検証不要)
    # が、例を見てわかるように、「A(40) + B(-39)」の様に、Bは負数にできる。
    # = Xは1以上なので-Aを超えることは無い。
    # なので、必要な情報は、「数値xの5乗 - 数値-(x-1)の5乗 >= 1億」を満たすタイミング。
    #  =>119。これが、ありえる最大パターン。(Aが119でBが-118というパターン)
    # Aが取りうる範囲は・・0~119  Bが取りうる範囲は・・-118~119
    #  =>このパターン数なら、全網羅できる。

    # for i in range(99999999):
    #     if pow(i, 5) + pow(-(i - 1), 5) >= 1000000000:
    #         print(i)
    #         pow(i, 5)
    #         break

Submission status: Accepted

Solution code:
x=int(input())
for i in range(-150,151):
  for j in range(-150,151):
    if(pow(i,5)-pow(j,5)==x):
      print(i,j)
      exit()

Submission status: Accepted

Solution code:
X = int(input())

for i in range(-200,200,1):
    for j in range(-200,200,1):
        if (i**5 - j**5) == X:
            print(str(i) + ' ' + str(j))
            break
    else:
        continue
    break

Submission status: Accepted

Solution code:
X = int(input())
flag = False
for A in range(-120, 120):
  for B in range(-120, 120):
    if (A**5 - B**5) == X:
      print(A, B)
      flag = True
      break
  if flag == True:
    break

Submission status: Accepted

Solution code:
X = input().split()
X = int(X[0])
ans = [0]*2

for i in range(-200,200):
    for j in range(-200,200):
        x = i**5 - j**5

        if x == X:
            ans = (i,j)
            break

print(' '.join(map(str,ans)))

Submission status: Accepted

Solution code:
X = int(input())

def solve():
    for A in range(-200, 201):
        for B in range(-200, 201):
            if (A**5)-(B**5)==X:
                print(A, B)
                return

solve()

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
X=int(input())

a=False
for i in range(10**3):
    if a==False:
        for j in range(-10**3,10**3):
            if i**5-j**5==X:
                print(i,j)
                a=True
                break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(x):
    D = {b**5:b for b in range(-200, 200)}
    for a in range(-200, 200):
        k = x - a**5
        if -k in D:
            return " ".join(map(str, [D[k],-a]))

x = int(input())
print(solve(x))

Submission status: Accepted

Solution code:
x = int(input())

a = 1
b = 0

def val():
    global a, b
    if pow(a,5) - pow(-b,5) == x:
        b = -b
        return True
    return pow(a,5) - pow(b,5) == x

while not val():
    if a >= b:
        b += 1
    else:
        a += 1
        b = 0
print(a,b)

Submission status: Accepted

Solution code:
X = int(input())

for A in range(-118, 120):
    for B in range(-119, 119):
        A5 = pow(A,5)
        B5 = pow(B,5)
        if( (A5-B5) == X):
            ans = str(A) + ' ' + str(B)
            break

print(ans)

Submission status: Accepted

Solution code:
X = int(input())
li = [i**5 for i in range(0,10000,1)]
for A in li:
    if A-X in li:#Bが自然数
        B = li.index(A-X)
        break
    elif A-X < 0:#Bが負の実数
        if abs(A-X) in li:
            B = (li.index((A-X)*(-1))) * (-1)
            break

print(li.index(A),B)

Submission status: Accepted

Solution code:
x = int(input())

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

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(0)

Submission status: Accepted

Solution code:
import sys
x = int(input())
for i in range(-159,159,1):
    for j in range(-159,159,1):
        if i**5 - j**5 == x:
            print(str(i)+' '+str(j))
            sys.exit()

Submission status: Accepted

Solution code:
x = int(input())

num_list = {}
result = [ 0, 0 ]

for i in range(121):
    num_list[i ** 5] = i

for i in num_list:
    temp = i - x
    if(abs(temp) in num_list):
        result[0] = num_list[i]
        if(temp < 0):
            result[1] = num_list[abs(temp)] * -1
        else:
            result[1] = num_list[temp]

        break

print('{} {}'.format(result[0], result[1]))

Submission status: Accepted

Solution code:
X = int(input())

for a in range(-118, 121):
    for b in range(-118, 121):
        if a**5 - b**5 == X:
            print(a, b)
            break
    else:
        continue
    break

Submission status: Accepted

Solution code:
# unihernandez22 & Vicfred
# https://atcoder.jp/contests/abc166/tasks/abc166_d
# math, probability
from random import randint

n = int(input())

for _ in range(10**6):
    x = randint(-200,200)
    y = randint(-200,200)
    if x**5 - y**5 == n:
        print(x,y)
        break;

Submission status: Accepted

Solution code:
# unihernandez22 & Vicfred
# https://atcoder.jp/contests/abc166/tasks/abc166_d
# math, probability
from random import randint

n = int(input())

for _ in range(10**6):
    x = randint(-200,200)
    y = randint(-200,200)
    if x**5 - y**5 == n:
        print(x,y)
        break;

Submission status: Accepted

Solution code:
# unihernandez22
# https://atcoder.jp/contests/abc166/tasks/abc166_d
# math
n = int(input())
for a in range(n):
    breaked = True
    for b in range(-1000, 1000):
        if a**5 - b**5 == n:
            print(a, b)
            break;
    else:
        breaked = False
    if breaked:
        break

Submission status: Accepted

Solution code:
n = int(input())
for a in range(n):
    breaked = True
    for b in range(-1000, 1000):
        if a**5 - b**5 == n:
            print(a, b)
            break;
    else:
        breaked = False
    if breaked:
        break

Submission status: Accepted

Solution code:
x = int(input())
a = [i for i in range(-119,121)]
b = [i for i in range(-120, 120)]
for i in a:
    for j in b:
        if i**5 - j**5 == x:
            print(i,j)
            exit()

Submission status: Accepted

Solution code:
M=120

X=int(input())

for a in range(-M,M+1):
    for b in range(-M,M+1):
        if a**5-b**5==X:
            A,B=a,b
            break

print(A,B)

Submission status: Accepted

Solution code:
x = int(input())

flag = 0

for i in range(-250,250):
    for j in range(-250,250):
        if(i**5 - j**5 == x):
            print(str(i) + ' ' + str(j))
            flag = True
            break
    if(flag):
        break

Submission status: Accepted

Solution code:
x = int(input())


for i in range(120):
    if x>i**5:
        for j in range(-100,0):
            ans = i**5-j**5
            if ans == x:
                print("{} {}".format(i,j))
                exit()
    else:
        for j in range(0,120):
            ans = i**5-j**5
            if ans == x:
                print("{} {}".format(i,j))
                exit()

Submission status: Accepted

Solution code:
def func(x,y):
    return x**5-y**5

x = int(input())
a = -200
b = 200
flag = False

for i in range(-199,200):
    for j in range(-200,199):
        if(func(i,j)==x):
            print(i,j)
            flag = True
            break
    if(flag):
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

    # i = 0
    # while True:
    #     if (i+1)**5 - i**5 > 10**9:
    #         break
    #     i+=1
    # print(i)

    for a in range(-119,120):
        for b in range(-119, 120):
            if a**5-b**5 == x:
                print(a, b)
                return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
X = int(input())

mid = -150
for A in range(-149,150):
    B1 = -150
    B2 = A-1
    A5 = A**5
    while B2-B1>1:
        mid = (B1+B2)/2
        if A5 - int(mid)**5 == X:
            break
        elif A5 - mid**5 <= X:
            B2 = mid
        else:
            B1 = mid
    if A5 - int(mid)**5 == X:
        break

print(A,int(mid))

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

x = ni()
ans_a = 0
ans_b = 0
for a in range(-120, 120):
    for b in range(-120, 120):
        if a**5 - b**5 == x:
            ans_a = a
            ans_b = b

print(ans_a, ans_b)

Submission status: Accepted

Solution code:
def main():
    x = int(input())
    for i in range(-118, 119):
        for j in range(-119, 118):
            if i ** 5 - j ** 5 == x:
                print(i, j)
                exit()


if __name__ == "__main__":
    main()

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:
X=int(input())
a=True
for A in range(118+121):
    if(a):
        for B in range(118+121):
            if((A-118)**5-(B-118)**5==X):
                print(A-118,B-118)
                a=False
                break

Submission status: Accepted

Solution code:
X=int(input())
a=True
for A in range(118+120):
    if(a):
        for B in range(118+120):
            if((A-118)**5-(B-118)**5==X):
                print(A-118,B-118)
                a=False
                break

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

x = ni()
for i in range(-1*10**3, 10**3+1):
    for j in range(-1*10**3,10**3+1):
        pres = i**5 - j**5 == x
        if pres:
            print(i,j)
            sys.exit(0)

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    for A in range(0, 201):
        for B in range(-201, 201):
            if pow(A, 5) - pow(B, 5) == X:
                print(A, B)
                return

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x = int(input())
ans = []
for A in range(10**5):
  for B in range(-100,10**4):
    if A**5 -B**5 == x:
      ans.append(A)
      ans.append(B)
      print(*ans)
      exit()

Submission status: Accepted

Solution code:
from itertools import product

x = int(input())

'''
 x = a^5 - b^5
   = (a - b)(a^4 + a^3 b + a^2 b^2 + a b^3 + b^4)

∵   (a - b)(a^4 + a^3 b + a^2 b^2 + a b^3 + b^4)
   = a^5 + a^4 b + a^3 b^2 + a^2 b^3 + a b^4
         - a^4 b - a^3 b^2 - a^2 b^3 - a b^4 - b^5
   = a^5 - b^5

a - b = ±1 となる解が存在する

このとき、

|x| = |a^4 + a^3 (a ± 1) + a^2 (a ± 1)^2 + a (a ± 1)^3 + (a ± 1)^4|
   ~= |a^4 + a^4 + a^4 + a^4 + a^4|
    = 5 a^4

であるから、1 <= x <= 10^9 に対して |a| <= (x / 5)^(1 / 4) となる

式の対象性より b についても同様な評価ができるので、

∴ -119 <= a, b <= 119 の範囲で解を探索すれば良い
'''

ab_s = product(range(-119, 120), range(-119, 120))

for a, b in ab_s:
    if x == (a ** 5 - b ** 5):
        print(a, b)
        exit(0)

Submission status: Accepted

Solution code:
import math
X=int(input())
x=1
while 1:
    if X<2*pow(x,5):
        break
    x+=1
while 1:
    M=pow(x,5)-X
    if M<0:
        M=-1*M
        if pow(M,0.2)-int(pow(M,0.2))<=pow(10,-6):
            print(x,-1*(int(pow(M,0.2))))
            break
    else:
        if pow(M,0.2)-int(pow(M,0.2))<=pow(10,-6):
            print(x,int(pow(M,0.2)))
            break
    x+=1