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:
# -*- coding: utf-8 -*-

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#保証されている
#分解するとa<10**3となる...はずだが

x=int(input())

for b in range(10**3):
    a = int((x+b**5)**(1/5))
    for i in range(a-1000,a+1000):#小さい数でも漏れが出ている
        if i**5+b**5==x:
            print(i,-b)
            exit()
for b in range(10**3):
    a2=(x-b**5)
    if a2<0:
        continue
    a = int(a2**(1/5))
    
    for i in range(a-1000,a+1000):
        if i**5-b**5==x:
            print(i,b)
            exit()

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
(X,) = [int(x) for x in input().split()]

M = 10 ** 5
fifthRoot = {}
for i in range(-M, M + 1):
    fifthRoot[i ** 5] = i

for b5 in fifthRoot.keys():
    if b5 + X in fifthRoot:
        a5 = b5 + X
        a = fifthRoot[a5]
        b = fifthRoot[b5]
        assert a ** 5 - b ** 5 == X
        print(a, b)
        exit()

Submission status: Accepted

Solution code:
import math
def main():

    X = int(input())
    v = int(pow(X, 0.25)) + 1
    for A in range(-v, v+1):
        c = pow(A, 5)
        for B in range(-v, v+1):
            if c - pow(B, 5) == X:
                return " ".join(map(str, [A, B]))
    return -1


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

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:
            break
    if A**5-B**5==X:
        break
print(A,B)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit
X = int(input())
for i in range(-120,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())

for a in range(1,1000):
    end=0
    for b in range(-1000,1000):
        if a**5-b**5 == x:
            end=1
            break
    if end==1:
        break

print(str(a)+' '+str(b))

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:
import sys
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

X=int(input())
ans=[0]*2
for i in range(0,1000):
    for j in range(i+1,1001):
        if(j**5-i**5==X):
            ans[0]=j
            ans[1]=i

for i in range(0,1001):
    for j in range(i+1,1001):
        if(j**5+i**5==X):
            ans[0]=j
            ans[1]=-i


print(*ans)

Submission status: Accepted

Solution code:
x=int(input())

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

Submission status: Accepted

Solution code:
X = int(input())

_range = int(pow(X,1/5))
for i in range(-2*_range-1,2*_range+2):
  for j in range(-2*_range-1,2*_range+2):
    if pow(i,5) - pow(j,5) == X:
      ans_a = i
      ans_b = j
      break
      
print(ans_a,ans_b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    x = int(input())
    for a in range(10**3):
        b = abs(a**5 - x)**0.2
        if a**5 - round(b)**5 == x:
            print(a, round(b))
            break
        if a**5 - round(-b)**5 == x:
            print(a, round(-b))
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
x = int(input())
#n, m = map(int, sys.stdin.readline().split())
#s = input()
#h = list(map(int, sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
X = int(input())
Alist = []
Blist = [0]
flag = 0
for i in range(1,10**4):
  Alist.append(i)
for j in range(1,10**4):
  Blist.append(j)
  Blist.append(-j)
for i in range(len(Alist)):
  for j in range(len(Blist)):
    if(Alist[i]**5 - Blist[j]**5 == X):
      print(Alist[i],Blist[j])
      flag = 1
      break
  if(flag==1):
    break

Submission status: Accepted

Solution code:
X = int(input())
for i in range(1, int(10**(9/2)) + 1):
  for j in range(-200, 200):
    if i**5 - j**5 == X:
      print(i, j)
      exit()

Submission status: Accepted

Solution code:
x = int(input())
lis = []
for i in range(-150,151):
    lis.append(i**5)
tab = [[0]*301 for _ in range(301)]
for j in range(301):
    for k in range(301):
        tab[j][k] = lis[j]-lis[k]
for l in range(301):
    for m in range(301):
        if tab[l][m] == x:
            print(l-150, m-150)
            exit()

Submission status: Accepted

Solution code:
from sys import stdin
import sys

X = int(input())
for i in range(-5000, 5001):
    for k in range(-5000, 5001):
        if i-k != 0 and (X/(i-k)).is_integer():
            if i**5-k**5 == X:
                print(i, k)
                sys.exit()

Submission status: Accepted

Solution code:
X = int(input())

n = 500

for i in range(-n, n + 1):
    flag = False
    for j in range(-n, n + 1):
        if i == j:
            continue
        if i ** 5 - j ** 5 == X:
            print(i, j)
            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()
    return divisors
make_divisors(10**9)
for i in range(0,200):
  for j in range(0,200):
    if i**5+j**5 == x:
      print(i,-j)
      quit()
l = make_divisors(x)
for i in l:
  b = 0
  a = b+i
  if (a**5-b**5)%10 != x%10:
    continue
  while True:
    a = b+i
    if a**5-b**5 < x:
      b += 1
    elif a**5-b**5 > x:
      break
    else:
      print(a,b)
      quit()
print(l)

Submission status: Accepted

Solution code:
import math


def read():
    X = int(input())
    return X, 


def f(a, b):
    return a**5 - b**5


def solve(X):
    for i in range(0, 1001):
        for j in range(-1000, 1001):
            if f(i, j) == X:
                return "{} {}".format(i, j)

if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    print("{}".format(outputs))

Submission status: Accepted

Solution code:
x = int(input())
target_ls = [0]
base = 1
base_ls = [0]
while True:
    new = (base)**5
    target_ls.append(new)
    target_ls.append(-new)
    base_ls.append(base)
    base_ls.append(-base)
    target_ls.sort()
    base_ls.sort()
    if target_ls[-1] - target_ls[-2] > 10**9:
        break
    base += 1
len_target= len(base_ls)
for i,a in enumerate(base_ls):
    for j,b in enumerate(base_ls):
        if target_ls[i] - target_ls[j] == x:
            ans = [a,b]
print(ans[0],ans[1])

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    for a in range(int(X**0.2)+1):
        for b in range(int(X**0.2)+1):
            if a**5 + b**5 == X:
                print(a, b*(-1))
                return
    for b in range(1, int(X**0.25)+1):
        temp = (X + b**5)**0.2
        if abs(temp - int(temp)) < 0.0001:
            print(int(temp), b)
            break
main()

Submission status: Accepted

Solution code:
x = int(input())
base = [0]
now = 1
while now ** 5 - base[-1] <= 10 ** 9:
  base.append(now ** 5)
  now += 1
for a,va in enumerate(base[1:],1):
  for b,vb in enumerate(base[:a]):
    if va - vb == x:
      print(a,b)
      break
    elif va + vb == x:
      print(a,-b)
      break

Submission status: Accepted

Solution code:
x=int(input())


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

for i in range(-3000,3000):
    for j in range(i,3000):
        if targetList[3000+j]-targetList[3000+i]==x:
            print(str(j)+" "+str(i))
            exit()

Submission status: Accepted

Solution code:
X = int(input())

div = []

sqrtX = int(X**0.5)+1
for i in range(1,sqrtX+1):
    if X % i == 0:
        div.append(i)
        div.append(X//i)

div = sorted(set(div))

for d in div:
    A = 0
    while True:
        B = A - d
        R = A**4 + A**3 * B + A**2 * B**2 + A* B**3 + B**4
        Y = (A-B) * R
        if Y == X:
            print(A,B)
            exit()

        B = d + A
        R = A**4 + A**3 * B + A**2 * B**2 + A* B**3 + B**4
        Y = (A-B) * R
        if Y == X:
            print(A,B)
            exit()
        if A > 1000:
            break
        A += 1

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:


k=input()
flag=0
for i in range(-200,200):
    for j in range(i,200):
        xd=pow(j,5)-pow(i,5)
        if(xd==k):
            print j,i
            flag=1
            break
    if(flag):
        break

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:
            a_ans=a
            b_ans=b
            break

print(a_ans,b_ans)