Problem:


Score : 400 points

Problem Statement

Give a pair of integers (A, B) such that A^5-B^5 = X.
It is guaranteed that there exists such a pair for the given integer X.

Constraints

1 \leq X \leq 10^9

X is an integer.

There exists a pair of integers (A, B) satisfying the condition in Problem Statement.

Input

Input is given from Standard Input in the following format:

X

Output

Print A and B, with space in between.
If there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.

A B

Sample Input 1

33

Sample Output 1

2 -1

For A=2 and B=-1, A^5-B^5 = 33.

Sample Input 2

1

Sample Output 2

0 -1



Sample input:
33


Sample output:
2 -1

Submission status: Accepted

Solution code:
X = int(input())
if X == 0:
  print(0,0)
else:
  for i in range(-121,122):
    for j in range(-121,122):
      if i==j:
        continue
      else:
        if X%(i-j) == 0:
          if X == i**5 - j**5:
            print(i,j)
            exit()

Submission status: Accepted

Solution code:
X = int(input())

a = 1

def f(x, a):
    return 5 * a * (x ** 4) - 10 * (a ** 2) * (x ** 3) + 10 * (a ** 3) * (x ** 2) - 5 * (a ** 4) * x + a ** 5

def df(x, a):
    y = 5 * (x ** 4) + (-20 * a + 10) * (x ** 3) + (30 * (a ** 2) - 30 * a + 10) * (x ** 2) + (-20 * (a ** 3) + 30 * (a ** 2) - 20 * a + 5) * x + 5 * (a ** 4) - 10 * (a ** 3) + 10 * (a ** 2) - 5 * a + 1
    return y

x = 0
a = 1
s = 0
while True:
    s += df(x, a)
    if s == X:
        break
    if s > X:
        x += 1
        a = 0
        s = 0
    a += 1

print(x, x-a)

Submission status: Accepted

Solution code:
x = int(input())
ans = [i**5 for i in range(200)]
for i in ans:
    for j in ans:
        if i - j == x:
            print(ans.index(i), ans.index(j))
            exit()
        if i + j == x:
            print(ans.index(i), -ans.index(j))
            exit()

Submission status: Accepted

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

    # divisors.sort()
    return divisors

def check_xy(alpha, beta):
    if alpha**2 + 4*beta < 0:
        return []

    x = (alpha + (alpha**2 + 4*beta)**0.5) // 2
    y = - (alpha - (alpha**2 + 4*beta)**0.5) // 2

    if (x - y) == alpha and x*y == beta:
        return [int(x), int(y)]
    else:
        return []


X = int(input())
divisor = get_divisor(X)


def check_beta(alpha, beta):
    if alpha**5 + 5*(alpha**3)*beta + 5*alpha*(beta**2) == X:
        return 1
    else:
        return 0

for alpha in divisor:
    rem = X // alpha
    # rem = a^4 + 5ba^2 + 5b^2
    rem -= alpha**4
    # rem = 5ba^2 + 5b^2
    if rem % 5 != 0:
        continue
    
    rem //= 5
    # rem = ba^2 + b^2

    if alpha**4 + 4*rem < 0:
        continue


    o_beta = int(( (alpha**4 + 4*rem)**0.5 - alpha**2) // 2)
    u_beta = int(( -(alpha**4 + 4*rem)**0.5 - alpha**2) // 2)

    # print(alpha, o_beta, u_beta, rem)

    if check_beta(alpha, o_beta) == 1:
        ans = check_xy(alpha, o_beta)
        
        if len(ans) == 2:
            print(ans[0], ans[1])
            break

    if check_beta(alpha, u_beta) == 1:
        ans = check_xy(alpha, u_beta)

        if len(ans) == 2:
            print(ans[0], ans[1])
            break

Submission status: Accepted

Solution code:
def main():
    x=int(input())
    for k in range(200):
        for a in range(400):
            if a**5-(a-k)**5==x:
                print(a,a-k)
                exit()
    
if __name__=='__main__':
    #print(68**5)
    main()

Submission status: Accepted

Solution code:
import collections
import sys

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

#####

X = int(input())

if X == 0:
  print("0 0")
  sys.exit()

x = abs(X)
c = make_divisors(x)
c.append(1)
c = sorted(c)
#print(c)


for i in range(len(c)):
  B = (c[i] // 2) * -1
  A = B + c[i]
  while True:
    Z = A**5 - B**5
    #print(A,B,c[i],Z)
    if Z == x:
      if X < 0:
        print(B,A)
      else:
        print(A,B)
      sys.exit()

    if Z > x:
      break    
      
    A += 1
    B += 1

Submission status: Accepted

Solution code:
import sys

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


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

    for b in range(10 ** 3):
        for a in range(10 ** 3):
            if pow(a, 5) - pow(b, 5) == x:
                print(a, b)
                exit()
            if pow(-a, 5) - pow(b, 5) == x:
                print(-a, b)
                exit()
            if pow(a, 5) - pow(-b, 5) == x:
                print(a, -b)
                exit()
            if pow(-a, 5) - pow(-b, 5) == x:
                print(-a, -b)
                exit()


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
X=int(input())

for n in range(200):
    for i in range(-200,200):
        x=i**5-(i-n)**5
        if x==X:
            print(str(i)+" "+str(i-n))
            break

Submission status: Accepted

Solution code:
x = int(input())

a = 0

while True:
    b5 = a**5 - x
    
    if b5 >= 0:
        for b in range(b5+1):
            if b**5 == b5:
                print(a, b)
                exit()
            if b**5 > b5:
                break
    else:
        b5m = -b5
        for bm in range(b5m+1):
            if bm**5 == b5m:
                print(a, -bm)
                exit()
            if bm**5 > b5m:
                break
    
    a += 1

Submission status: Accepted

Solution code:
import sys

inputLine=input()
X=int(inputLine)

MIN = -1000
MAX = 1000

for A in range(MIN, MAX+1):
    for B in range(MIN, MAX+1):
        if A**5 - B**5 == X:
            print(A, B)
            sys.exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi, pow
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    X = intinput()
    digit = 256  # int(pow(X, 1/5))+1
    nums = []
    for i in range(digit+1):
        num = i**5
        nums.append((i, num))
        nums.append((-1*i,-1*num))

    for a in nums:
        for b in nums:
            if a[1] - b[1] == X:
                print(a[0], b[0])
                exit()

Submission status: Accepted

Solution code:
X = int(input())
flag = 0
A = 0
B = 0
for i in range(0,100000):
  if flag== 1:
    break
  for j in range(i,100000):
    
    x = i**5 + j**5
    #print(x)
    if x == X:
      A = i
      B = -j
      flag = 1
      break
    elif x > X:
      break
for i in range(1,100000):
  if flag == 1:
    break
  for j in range(0,i):
    x = i**5 - j**5
    if x == X:
      A = i
      B = j
      flag = 1
      break
    elif x < X:
      break
  
      
print("{} {}".format(A,B))

Submission status: Accepted

Solution code:
x=int(input())
D=[1]
for i in range(2,int(x**0.5)+1):
    if x%i==0:
        D.append(i)
for d in D:
    for i in range(1000):
        if i**5-(i-d)**5==x:
            print(i,i-d)
            exit()

Submission status: Accepted

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

x = int(input())
for div in divisors(x, reverse=True):
    b = -(div//2)
    a = div + b
    exist = False
    i = 0
    while True:
        val = (a+i)**5 - (b+i)**5
        if val == x:
            exist = True
            break
        if val > x:
            break
        i += 1
    if exist:
        print(a+i, b+i)
        break

Submission status: Accepted

Solution code:
import sys

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

x = int(input())
## 上界を決める
if x == 1:
    print("1 0")
    sys.exit()

y = (x-1)//5
A = 0
C = 0

while y>C:
    A += 1
    C = (A**4) + (2*(A**3)) + (2*(A**2)) + A

## 割り切れたら終わり
if (A+1)**5-A**5 == x:
    print(str(A+1)+" "+str(A))
    sys.exit()


## 約数を列挙
divs = make_divisors(x)
divs = divs[1:]
for i in divs:
    for j in range(A):
        a = j+1
        b = a-i
        if a**5-b**5 == x:
            print(str(a)+" "+str(b))
            sys.exit()

Submission status: Accepted

Solution code:
X = int(input())
for i in range(1000):
    for k in range(1000):
        if i**5 + k ** 5 == X:
            print("{} {}".format(i,k*-1))
            quit()
        elif i**5 - k**5 == X:
            print("{} {}".format(i,k))
            quit()

Submission status: Accepted

Solution code:
def main():
    X = int(input())  # 文字列または整数(一変数)

    for B in range(0, 1000):
        for A in range(B, 1000):
            if A**5 - B**5 == X:
                print(A, B, sep=" ")
                return
            if A**5 + B**5 == X:
                print(A, -B, sep=" ")
                return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys

x =int(input())

app = []
for i in range(0,10000):
    app.append(i**5)

flag = False
store=[]
for i in app:
    for j in app:
        if i - j == x:
            store.append(i**(1/5))
            store.append(j**(1/5))
            flag = True
            break
        elif -i - j == x:
            store.append(i**(1/5))
            store.append(j**(1/5))
            flag = True
            break
        elif -i + j == x:
            store.append(i**(1/5))
            store.append(j**(1/5))
            flag = True
            break
        elif i + j == x:
            store.append(i**(1/5))
            store.append(j**(1/5))
            flag = True
            break
    if flag:
        break

x1 = int(store[0])
y1 = int(store[1])

if (-x1)**5 - y1**5 ==x:
    x1 = x1
    y1 = y1
elif x1**5 - (-y1)**5 ==x:
    x1 = x1
    y1 = -y1
elif (-x1)**5 - (-y1)**5 ==x:
    x1 = -x1
    y1 = -y1
    
print(str(x1) + " " +str(y1) )

Submission status: Accepted

Solution code:
X = int(input())

L = [0] * (2 * 10**4 + 3)
for a in range(-10**4, 10**4 + 1):
    L[a + 10**4] = a**5


for a in range(-10**3, 10**3 + 1):
    for b in range(-10**3, 10**3 + 1):
        if L[a + 10**4] - L[b + 10**4] == X:
            print(a, b)
            import sys
            sys.exit()

Submission status: Accepted

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

import math

X = int(input())
A = 1
found = False

while True:
    a5 = math.pow(A, 5)
    b5max = math.pow(A - 1, 5)
    if a5 + b5max >= X and a5 - b5max <= X:
        found = True
        for B in range(A):
            b5 = math.pow(B, 5)
            if a5 - b5 == X:
                print(A, B)
                break
            if a5 + b5 == X:
                print(A, -B)
                break
        A += 1
    elif found:
        break
    else:
        A += 1

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit
from collections import defaultdict

setrecursionlimit(10 ** 9)


def input():
    return stdin.readline().strip()


def binary_search(n):
    left, right = 0, 10 ** 10
    while right - left > 1:
        mid = (left + right) // 2
        if mid ** 5 <= n:
            left = mid
        else:
            right = mid

    return left


X = int(input())
for i in range(10 ** 1000):
    B = i
    A5 = X + B ** 5
    n = binary_search(A5)
    if n ** 5 == A5:
        print(n, B)
        break

    B = -i
    A5 = X + B ** 5
    if A5 >= 0:
        n = binary_search(A5)
    else:
        n = -binary_search(-A5)
    if n ** 5 == A5:
        print(n, B)
        break

Submission status: Accepted

Solution code:
x = int(input())

is_get = False
for a in range(10000):
    for b in range(a + 1):
        aa = a ** 5
        bb = b ** 5
        xx = abs(x)
        if aa - bb == xx:
            if x >= 0:
                print(a, b)
            else:
                print(-a, -b)
            is_get = True
            break
        elif aa + bb == xx:
            if x >= 0:
                print(a, -b)
            else:
                print(-a, b)
            is_get = True
            break
    if is_get:
        break

Submission status: Accepted

Solution code:
ans = int(input())
res = 10*round(ans**0.2)

for i in range(-res, res+1):
    for j in range(-res, res+1):
        if i**5 - j**5 == ans:
            print(i,j)
            exit()

Submission status: Accepted

Solution code:
X = int(input())

gojyous = []

for i in range(-200, 201):
    gojyous.append(i ** 5)

#print(gojyous)

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

Submission status: Accepted

Solution code:
x = int(input())

for i in range(-1000,1000) :
    flag = 0
    for j in range(-1000,i) :
        if x%(i-j) != 0 :
            continue
        v = x//(i-j)
        c = i**4+j**4+i*j*(i**2+i*j+j**2)
        if v == c :
            print(i,j)
            flag = 1
            break
    if flag == 1 :
        break

Submission status: Accepted

Solution code:
x = int(input())
l = []
for i in range(-400,400):
    l.append(i**5)
ans =[]
for i in l:
    for j in l:
        if i - j == x:
            ans.append([i,j])
i,j = ans[0][0],ans[0][1]
print(l.index(i)-400,l.index(j)-400)

Submission status: Accepted

Solution code:
# coding: utf-8
from bisect import bisect_left


def solve(*args: str) -> str:
    x = int(args[0])

    P = [pow(i, 5) for i in range(128)]
    ret = None
    for b, b5 in enumerate(P):
        a5 = x+b5
        like_a = bisect_left(P, a5)
        if like_a < len(P):
            if P[like_a] == a5:
                ret = (like_a, b)
                break

        a5 = abs(x-b5)
        like_a = bisect_left(P, a5)
        if like_a < len(P):
            if P[like_a] == a5:
                ret = (like_a if b5 < x else -like_a, -b)
                break

    return ' '.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


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

    divisors.sort()
    return divisors


def check(x, y):
    return x ** 4 + x ** 3 * y + x ** 2 * y ** 2 + x * y ** 3 + y ** 4


X = readint()
l = make_divisors(X)

ans_A = 0
ans_B = 0
for n in l:
    # n = A - B
    A = n // 2
    B = A - n
    while A ** 5 - B ** 5 <= X:
        if check(A, B) == (X // n):
            ans_A = A
            ans_B = B
            break
        else:
            A -= 1
            B -= 1

    if ans_A:
        break


print(ans_A, ans_B)

Submission status: Accepted

Solution code:
x = int(input())
a = {i**5 for i in range(10**3)}
for p in a:
	if abs(p-x) in a:
		if p-x < 0:
			q = x-p
			print(int(p**(1/5)),int(-q**(1/5)))
			break
		else:
			q = p-x
			print(int(p**(1/5)),int(q**(1/5)))
			break

Submission status: Accepted

Solution code:
num=int(input())

def cal(num):
    return num*num*num*num*num

A=0
while(1):
    B=0
    while(cal(A)-cal(B)>num):
        B+=1
    if cal(A)-cal(B)==num:
        print(str(A)+" "+str(B))
        break
    B=0
    while(cal(A)-cal(B)<num):
        B-=1
    if cal(A)-cal(B)==num:
        print(str(A)+" "+str(B))
        break
    A+=1

Submission status: Accepted

Solution code:
x = int(input())
for i in range(int(x**(1/5))+1):
  ii = i**5
  for j in range(0,i+1):
    if ii + j**5 == x:
      print(i,-j)
      exit()
for i in range(2,1000):
  ii = i**5
  for j in range(1,i):
    if ii - j**5 == x:
      print(i,j)
      exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import pow, ceil
from itertools import product

X = int(input())
max_X = ceil(pow(10 ** 9, 1 / 5))

for a, b in product(range(-2 * max_X, 2 * max_X + 1), repeat=2):
    if (a ** 5 - b ** 5) == X:
        print(a, b)
        break

Submission status: Accepted

Solution code:
def solve(x):

    a = -1000
    while a <= 1000:
        b = -1000
        while b < 1000 :
            if x + b **5 == a**5:
                break
            else:
                b += 1
        if x + b **5 == a**5:
            break
        else:
            a+=1

    return "{0} {1}".format(a,b)

if __name__ == "__main__":
    x = int(input())
    print(solve(x))

Submission status: Accepted

Solution code:
x = int(input())

for i in range(-4000,4000) :
    flag = 0
    for j in range(-4000,i) :
        if x%(i-j) != 0 :
            continue
        v = x//(i-j)
        c = i**4+j**4+i*j*(i**2+i*j+j**2)
        if v == c :
            print(i,j)
            flag = 1
            break
    if flag == 1 :
        break

Submission status: Accepted

Solution code:

x=int(input())

def enum_div(n):
    ir=int(n**(0.5))+1
#    ret=[]
    ret=set()
    for i in range(1,ir):
        if n%i == 0:
            ret.add(i)
#            ret.append(i)
            if (i!= 1) & (i*i != n):
#                ret.append(n//i)
                ret.add(n//i)
    return ret

ret=enum_div(x)

y=20000
for ai in range(-y,y):
    yn=""
    for r in ret:
        bi=ai-r
        if ai**5-bi**5==x:
            yn="YES"
            break
        bi=ai+r
        if ai**5-bi**5==x:
            yn="YES"
            break
    if yn=="YES":
        break

if yn=="YES":
    print(ai,bi)

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    X = int(input())

    max_num = int(2 * (10 ** 9) ** (1/5))

    is_flag = False
    for i in range(-1*max_num, max_num):
        for j in range(-1*max_num, max_num):
            if i ** 5 - j ** 5 == X:
                print(i, j)
                is_flag = True
                break
        
        if is_flag:
            break





if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
for B in range(-10 ** 3, 10 ** 3):
    A_5 = B ** 5 + X
    A = A_5 ** (1 / 5)
    if type(A) is not float:
        continue
    A = int(A)
    if A ** 5 == A_5:
        print(A, B)
        exit()

Submission status: Accepted

Solution code:
def find(n):
  dif = 0
  i = 0
  while dif <=n:
    i+=1
    dif=i**5-(i-1)**5
  return i


X= int(input())
lim = find(X)
condition = True 
for i in range(lim):
  if condition:
    puissance = i**5-X
    signe = (abs(puissance)//puissance)
    entier = int(((puissance*signe)**(1/5)))
    if entier**5 == signe*puissance:
      print(i, entier*signe)
      condition = False

Submission status: Accepted

Solution code:
X = int(input())
flg = False

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

div_arr = sorted(make_divisors(X))

def cal_p2(a,b):
  return pow(a,4) + pow(a,3)*pow(b,1) + pow(a,2)*pow(b,2) + pow(a,1)*pow(b,3) + pow(b,4)


for div in div_arr:
  p1 = div
  p2 = X//div
  a = p1//2-1
  while True:
    a += 1
    b = a - p1
    if p2==cal_p2(a,b):
      flg = True
      break
    elif p2<cal_p2(a,b):
      break
  if flg:
    break
    
print(a,b)

Submission status: Accepted

Solution code:
X = int(input())

# if A > B > 0 then
#  X >= 5A^4 - 10A^3 + 10A^2 -5A + 1


def fn(a):
    return 5 * a**4 - 10 * a**3 + 10 * a**2 - 5 * a + 1


A_max = 0
for a in range(3, 1000):
    if fn(a) > X and a**5 > X:
        A_max = a
        break

s = dict()
for a in range(0, A_max):
    s[a**5] = a

for a5 in s:
    if a5 - X in s:
        print(s[a5], s[a5 - X])
        exit()
    if X - a5 in s:
        print(s[a5], -s[X - a5])
        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)
 
    return divisors


d = make_divisors(x)


for i in d:
    for b in range(-10000,10000):
        a = i + b
        if x // i == a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4:
            ans = [str(a),str(b)]
            break
        
print(*ans)

Submission status: Accepted

Solution code:
x = int(input())

c5 = []
iter5 = []
for i in range(-1000, 1000, 1): # 100
    c5.append(i**5)
    iter5.append(i)

a, b = 0, 0
for i in range(len(c5)):
    for j in range(len(c5)):
        if (c5[i] - c5[j]) == x:
            a, b = iter5[i], iter5[j]
            break

print(a,b)

Submission status: Accepted

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

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 calc(a, b):
    return a ** 4 + a * (b ** 3) + (a * b) ** 2 + b * (a ** 3) + b ** 4

X = int(input())
# c=a-b
for c in make_divisors(X):
    for b in range(-10000, 10000):
        a = c + b
        if calc(a, b) == X / c:
            print(a, b)
            break

Submission status: Accepted

Solution code:
x=int(input())

s=0
a=-1
z5=[]
ans=[]
aans=0
bans=0
while(s==0):
    a+=1
    z5.append(a**5)
    if (x+a**5) in z5:
        bans=a
        break
    elif  (x-a**5) in z5:
        bans=-a
        break

    elif (a**5-x) in z5:
        aans=a
        break
        

if aans==0:
    aans=int((x+bans**5)**(1.0/5.0))
if bans==0:
    bans=int((aans**5-x)**(1.0/5.0))

print(aans,bans)

Submission status: Accepted

Solution code:
X = abs(int(input()))
size = 1000
L = [i**5 for i in range(size)]
if X == 0:
    print(0, 0)
for l in range(size):
    for m in range(l+1):
        if L[l] + L[m] == X:
            print(l, -m)
            exit(0)
        if L[l] - L[m] == X:
            print(l, m)
            exit(0)

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:
            if i != n // i:
                divisors.append([i,n//i])
            else:
                divisors.append([i,i])
    return divisors
l=make_divisors(x)
for x,y in l:
    for i in range(10**4):
        p=i-x
        if i**4+(i**3)*p+(i**2)*(p**2)+i*(p**3)+p**4==y:
            print(i,p)
            break

Submission status: Accepted

Solution code:
x=int(input())
ulist=[]

for i in range(1,int(x**0.5)+1):
    if x%i==0:
        ulist.append(i)

def root(n):
    hanbun=int(n**0.5)
    if hanbun**2==n:
        return True
    return False
        

def niji(a,b,c):
    hanbetu=b**2-4*a*c
    if hanbetu>=0:
        if root(hanbetu):
            one=-b+int(hanbetu**0.5)
            two=-b-int(hanbetu**0.5)
            ans=[]
            if one%(2*a)==0:
                ans.append(one//(2*a))
            if two%(2*a)==0:
                ans.append(two//(2*a))
            if ans!=[]:
                return ans
    return False
# print(ulist)        
for u in ulist:
#     print(u)
#     print(5*u,5*(u**3),u**5-x)
    if niji(5*u,5*(u**3),u**5-x):
        plist=niji(5*u,5*(u**3),u**5-x)
#         print(plist)
        for p in plist:
            if niji(1,-u,-p):
                alist=niji(1,-u,-p)
                print(alist[0],alist[0]-u)
                break

Submission status: Accepted

Solution code:
n=int(input())
a=0
b=0
wa=0
frag=1
tmpa=[]
while frag:
    for i in range(wa+1):
        a=i
        b=wa-i
        #print(a,b)
        if a ** 5 - b ** 5 == n:
            frag=0
            break
        b = 0 - b
        #print(a, b)
        if a ** 5 - b ** 5 == n:
            frag=0
            break
    wa+=1
print(a,b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(1000):
         a.append(i ** 5)
for i in range(1000):
         for j in range(-1000,1000):
                  if (a[i]) - (j ** 5) == n:
                           print(i,j)
                           exit()

Submission status: Accepted

Solution code:
x = int(input())

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

for a in range(-1000, 1001):
    for b in range(-1000, 1001):
        if fs[a + 1000] - fs[b + 1000] == x:
            print(a, b)
            exit()

Submission status: Accepted

Solution code:
x = int(input())
import math
for i in range(10**5):
    z = (x - i ** 5)
    if z == 0:
        b = 0
    else:
        b = (x - i ** 5) ** (1/5)
    #print(i, b)
    if i ** 5 - math.floor(abs(b)) ** 5 == x:
        print(i, math.floor(abs(b)))
        exit()
    if i ** 5 - (-math.floor(abs(b))) ** 5 == x:
        print(i, -math.floor(abs(b)))
        exit()
    if i ** 5 - math.ceil(abs(b)) ** 5 == x:
        print(i, math.ceil(abs(b)))
        exit()
    if i ** 5 - (-math.ceil(abs(b))) ** 5 == x:
        print(i, -math.ceil(abs(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()
    return divisors

kouho = make_divisors(x)

#A>0,B<0
for y in kouho:
    for a in range(1000):
        b = a-y
        if a**5 - b**5 == x:
            print(a,b)
            break

Submission status: Accepted

Solution code:
x = int(input())
a = 0
b = 0
for i in range(-500, 500):
    for j in range(-500, 500):
        if (i ** 5) - (j ** 5) == x:
            a = i
            b = j
            break
print("{} {}".format(a, b))