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

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

Submission status: Accepted

Solution code:
def resolve():
    x = int(input())
    five = []
    for i in range(-1000, 1001):
        five.append(i ** 5)

    for i in range(len(five)):
        for j in range(len(five)):
            if x == abs(five[i] - five[j]):
                if five[i] >= five[j]:
                    print("{} {}".format(i - 1000, j - 1000))
  
                else:
                    print("{} {}".format(j - 1000, i - 1000))

                    exit()

resolve()

Submission status: Accepted

Solution code:
import numpy as np
x = int(input())
tmp_list=[]
c=0
tmp_2=0
while(1):
    tmp_1=c**5
    if (tmp_1 - tmp_2)<=x:
        tmp_list+=[tmp_1]
    else:
        break
    tmp_2=tmp_1
    c+=1
 
def せいがわ(target:list,x) -> list:
    for i in np.flipud(target):
        for j in target:
            tmp=i+j
            if tmp==x:
                return [int(i**(1/5)),int(j**(1/5))*-1]
            if tmp>x:
                break
    return 0
 
def ふがわ(target:list,x) -> list:
    for i in np.flipud(target):
        for j in target:
            tmp=i-j
            if tmp==x:
                return [int(i**(1/5)),int(j**(1/5))]
            if tmp<x:
                break
    return 0
  
ans=ふがわ(tmp_list,x)
if ans==0:
    ans=せいがわ(tmp_list,x)
print(ans[0],ans[1])

Submission status: Accepted

Solution code:
#!python3.8
# -*- coding: utf-8 -*-
# abc166/abc166_d
import sys
import math

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    X = i2n()
    for A in range(0, X+1):
        B_5 = A**5 - X
        if B_5 == 0:
            print(A, 0)
            return
        if B_5 > 0:
            B = int(B_5**0.2)
        else:
            B = int(-1 * (-B_5)**0.2)
        if B**5 == B_5:
            print(A, B)
            return
    return

main()

Submission status: Accepted

Solution code:
pow5 = [0, 1, 32, 243]

def find_x(x):
    while True:
        size = len(pow5)
        for a in range(size):
            for b in range(size):
                pp = pow5[a] - pow5[b]
                if pp == x:
                    return a, b
                pm = pow5[a] + pow5[b]
                if pm == x:
                    return a, -b
                mp = - pow5[a] - pow5[b]
                if mp == x:
                    return -a, b
                mm = - pow5[a] + pow5[b]
                if mm == x:
                    return -a, -b
        pow5.append(size ** 5)


X = int(input())
A, B = find_x(X)
print(A, B)

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    
    for a in range(-1000, 1000):
        for b in range(-1000, 1000):
            c = a ** 5 - b ** 5
            
            if c == X:
                print(a, b)
                return
    
    
    
    
    



main()

Submission status: Accepted

Solution code:
x=int(input())
l=[]
for i in range(1,int(x**0.5)+1):
  if x%i==0:
    l.append(i)
    l.append(x//i)
for i in l:
  for j in range(int(x**0.2)+100,0,-1):
    A=j
    B=j-i
    if A<B:
      break
    if A**5-B**5==x:
      print(A,B,sep=' ')
      exit()

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    x = II()
    divs = enumerate_divs(x)
    # print(divs)

    for r,q in divs:
        # for i in range(r+1):
        i = 0
        while True:
            a = i
            b = a-r
            # print(a,b)
            d = a**5-b**5
            if d > x and b >= 0:
                i = 0
                break
            if d==x:
                print(a, b)
                return None
            i+=1


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())

#x^5-y^5=(x-y)(x^4+x^3y+x^2y^2+xy^3+y^4)

#for x in range(1, 121):
#  if ((x**5) - ((x-1)**5)) >= 1000000000:
#    print(x)

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

Submission status: Accepted

Solution code:
x = int(input())

lower = -1
upper = -1
for i in range(100000000):
    pow5 = pow(i, 5)
    if lower == -1 and pow5 >= x:
        lower = i - 1
        break

for i in range(lower, 100000000):
    pow5 = pow(i, 5)
    if upper == -1 and pow5 - pow(i-1, 5) >= x:
        upper = i
        break

for a in range(-upper-1, upper+1):
    a5 = pow(a, 5)
    for b in range(-upper-1, upper+1):
        if a5 - pow(b, 5) == x:
            print(a, b)
            exit(0)

# 0, 0
print(0, 0)

Submission status: Accepted

Solution code:
X = int(input())

for a in range(-128,129):
  for b in range(-128, 129):
    if int(a ** 5 - b ** 5) == X:
      print(str(a) + " " + str(b))
      exit()

Submission status: Accepted

Solution code:
import sys
import math
def make_divisors(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 f(p,T):
    q=T//p
    #print(p,q)
    m=int(math.sqrt(T))+1
    for j in range(-m-1,m+1):
        i = j+ p
        k=i**2*(i*(i+j) + (j**2)) + (j**3)*(i+j)
        if (k==q):
            print(i,j)
            return True
    else:
        return False
T=int(input())
ya=make_divisors(T)
for p in ya:
    if f(p,T):
        break

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)
            break
    if a**5 - b**5 == x:
        break

Submission status: Accepted

Solution code:
x = int(input())

x2 = int(x**0.5)
if x2**5 == x:
  print(x2, 0)
  exit()
elif x2**5-1 == x:
  print(X2, -1)
  exit()

for i in range(1, int(x**0.5)+2):
  if x%i == 0:
    tmp1 = 0
    tmp2 = 0
    a1 = i
    b1 = 0
    a2 = i-1
    b2 = -1
    while abs(tmp1) <= x**2 or abs(tmp2) <= x**2:
      tmp1 = a1**5 - b1**5
      tmp2 = a2**5 - b2**5
      if tmp1 == x:
        print(a1, b1)
        exit()
      elif tmp2 == x:
        print(a2, b2)
        exit()
      a1+=1
      b1+=1
      a2-=1
      b2-=1

Submission status: Accepted

Solution code:
x = int(input())

for b in range(-1000,1000):
  for a in range(-1000,1000):
    if a**5-b**5==x:
      print(a,b)
      break
  else:
    continue
  break

Submission status: Accepted

Solution code:
import sys

x=int(input())
for i in range(-120,120):
    for j in range(-120,120):
        if i*i*i*i*i-j*j*j*j*j==x:
            print(str(i)+' '+str(j))
            sys.exit()

Submission status: Accepted

Solution code:
X=int(input())
A=0
while 1:
    B=0
    while pow(A,5)-pow(B,5)>X:
      B+=1
    while pow(A,5)-pow(B,5)<X:
      B-=1
    if pow(A,5)-pow(B,5)==X:
      print('{} {}'.format(A,B))
      exit()
    A+=1

Submission status: Accepted

Solution code:
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
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 MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    x=I()
    if x==1:
        print(1,0)
    else:
        f=0
        for i in range(1,400):
            for j in range(i-1,-400,-1):
                if (i**5)-(j**5)==x:
                    print(i,j)
                    f=1
                    break
            if f==1:
                break
        else:
            print(x,0)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def hoge():
    X = int(input())
    for a in range(0,int(X**(1/5))+1):
        for b in range(0,a+1):
            if a**5+b**5 == X:
                return (a,-b)
    for a in range(int(X**(1/5)),10**9):
        for b in range(0,a+1):
            if a**5-b**5 == X:
                return (a,b)


result = hoge()
print(result[0], result[1])

Submission status: Accepted

Solution code:
x = int(input())

root = int(x**(0.2))

flag = 0
for i in range(root - 400, root + 400):
    for j in range(-100, root + 400):
        if i!=j:
            if x%(i-j) == 0:
                if i**5-j**5 == x:
                    print(i, j)
                    flag = 1
                    break
    if flag:
        break

Submission status: Accepted

Solution code:
x = int(input())

div = set()
for i in range(1, int(x**0.5)+1):
    if x % i == 0:
        div.add(i)
        div.add(x//i)

div = list(div)

for d in div:
    for a in range(int(pow(x, 1/2))+1):
        b = a - d
        if a**5 - b**5 == x:
            print(a, b)
            break

Submission status: Accepted

Solution code:
def cal(a,b):
    return a**5-b**5

def main():
    X = int(input())
    update = True
    for i in range(10**3):
        for j in range(10**3):
            if cal(i,j) == X:
                a,b = i,j
                update = False
                break
            if cal(i,-j) == X:
                a,b = i,-j
                update = False
                break
        if not update:
            break

    print(a,b)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

X = int(read())
A = np.array([pow(i, 5) for i in range(7000)])

for i, B_f in enumerate(A):
    for sig in [1, -1]:
        diff = A - (sig * B_f)
        if (diff == X).any():
            A_f = X + (sig * B_f)
            AA = A.tolist().index(A_f)
            B = A.tolist().index(B_f)
            print(AA, sig * B)
            sys.exit()

Submission status: Accepted

Solution code:
x = int(input())
i = 0
while i**5 < x and (i + 1)**5 < x:
    i += 1
flag = 0
for j in range(x):
    if flag:
        break
    tmp1 = j ** 5
    if tmp1 < x:
        start, end = 0, x - tmp1
        while start <= end:
            middle = (start + end)//2
            if tmp1 + middle ** 5 > x:
                end = middle - 1
            elif tmp1 + middle ** 5 == x:
                flag = 1
                print(j, -middle)
                break
            else:
                start = middle + 1
    elif tmp1 == x:
        print(j, 0)
        break
    else:
        start, end = 0, tmp1 - x
        while start <= end:
            middle = (start + end) // 2
            if tmp1 - middle ** 5 > x:
                start = middle + 1
            elif tmp1 - middle ** 5 == x:
                flag = 1
                print(j, middle)
                break
            else:
                end = middle -1

Submission status: Accepted

Solution code:
X = int(input())

num = [i ** 5 for i in range(400)]

for A in range(400):
    for B in range(400):
        if num[A] + num[B] == X:
            print(A, (-1)*B)
            exit(0)
        elif num[A] - num[B] == X:
            print(A, B)
            exit(0)

Submission status: Accepted

Solution code:
X = int(input())

maxAplus = int(pow(X, 1.0/5.0))
maxAsub = int(pow(X, 1.0/4.0))

for a in range(1, maxAplus+1):
    for b in range(a):
        if pow(a, 5) + pow(b, 5) == X:
            print(a, -b)
            exit()
        elif pow(a, 5) + pow(b, 5) > X:
            break

for a in range(1, maxAsub+1):
    for b in range(a):
        if pow(a, 5) - pow(b, 5) == X:
            print(a, b)
            exit()

Submission status: Accepted

Solution code:
import itertools
X=int(input())
li=[i**5 for i in range(128)]#
for v in itertools.permutations(li, 2):
    v=list(v)
    v.sort()
    if v[1]-v[0]==X:#両方プラスの時
        A=v[1]**0.2
        B=v[0]**0.2
        print(str(int(A))+" "+str(int(B)))
        break
    elif v[0]+v[1]==X:#v[0]がマイナスの時
        A=v[1]**0.2
        B=-1*((v[0])**0.2)
        print(str(int(A))+" "+str(int(B)))
        break
#ans=(i-j)*(i**4+(i**3)*j+(i**2)*(j**2)+i*(j**3)+j**4)
#(ａ－ｂ)(ａ⁴＋ａ³ｂ＋ａ²ｂ²＋ａｂ³＋小さい

Submission status: Accepted

Solution code:
X = int(input())

def calc():
    for A in range(-200, 201, 1):
        for B in range(-200, 201, 1):
            if pow(A, 5) - pow(B, 5) == X:
                print(A, B)
                return

calc()

Submission status: Accepted

Solution code:
X = int(input())
N1 = 0
N2 = 0

A = [0] * 1000
for i in range(1000):
    A[i] = (i-500)**5

for i in range(1000):
    for j in range(1000):
        if A[i] - A[j] == X:
            N1 = i-500
            N2 = j-500
            break

print(N1,N2)

Submission status: Accepted

Solution code:
x=int(input())
for p in range(1,int(x**0.5)+1):
    if x%p==0:
        q=x//p
        for a in range(int(x**0.5)+1):
            b=a-p
            if a**4+a**3*b+a**2*b**2+a*b**3+b**4==q:
                print(a,b)
                exit()

Submission status: Accepted

Solution code:
x = int(input())
d = dict()
for i in range(-200, 201):
	d[i**5] = i
for i in d:
	if x+i in d:
		print(d[x+i], d[i])
		break

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    x=int(readline())
    flag=False
    for A in range(-200,201):
        for B in range(-200,201):
            if A**5-B**5==x:
                print(A,B)
                flag=True
        if flag:
            break

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
X = int(input())
A = [(i**5) for i in range(0, 1000)]
res = []
for i in range(len(A)):
  a = A[i]
  for j in range(len(A)):
    b = -A[j]
    cal = a - b
    cal2 = a + b
    if cal == X:
      print(i, -j)
      exit()
    elif cal2 == X:
      print(i, j)
      exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def prime_factorize(n):
    """Calculate prime factorization and return unique numbers and 1.
    """
    ans = set()
    ans_add = ans.add
    ans_add(1)
    while n % 2 == 0:
        ans_add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans_add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        ans_add(n)
    return ans


def main():
    x = int(input())
    # 素因数分解してユニークな因数を取る。
    insu = prime_factorize(x)
    # a^5 - b^5 も a - b も，ある因数の倍数となる。
    # ここは a >= b と仮定すると，a は正でなくては，xが負になっちゃう。

    b_min = -int(x ** (1 / 5))
    for n in insu:
        b = b_min
        while 1:
            a = b
            while 1:
                a += n
                if a < 0:
                    continue
                cand = a ** 5 - b ** 5
                if cand == x:
                    return f'{a} {b}'
                elif cand > x:
                    break
            b += 1
            if (b + n) ** 5 - b ** 5 > x:
                break


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

Submission status: Accepted

Solution code:
X = int(input())

for a in range(1000):
    for b in range(1000):
        if a ** 5 - b ** 5 == X:
            print(f"{a} {b}")
            exit()
        elif (-a) ** 5 - b ** 5 == X:
            print(f"{-a} {b}")
            exit()
        elif a ** 5 - (-b) ** 5 == X:
            print(f"{a} {-b}")
            exit()
        elif (-a) ** 5 - (-b) ** 5 == X:
            print(f"{-a} {-b}")
            exit()

Submission status: Accepted

Solution code:
X=int(input())
flag=0
for i in range(10**9):
    A=i**5
    B=A-X
    if B<0:
        for j in range(10**9):
            b=j**5
            if B+b==0:
                ans1=i
                ans2=-j
                flag=1
                break
            elif B+b>0:
                break
    else:
        for j in range(10**9):
            b=j**5
            if B-b==0:
                ans1=i
                ans2=j
                flag=1
                break
            elif B-b<0:
                break
    if flag==1:
        break
print(ans1,ans2)

Submission status: Accepted

Solution code:
x = int(input())
a = 2
b = 0
A = []
A.append(1 ** 5 - x)

while True:
    if (a + 1) ** 5 - a ** 5 > 10 ** 10:
        break
    A.append(a ** 5 - x)
    a = a + 1

while True:
    if b ** 5 in A:
        break
    elif -b ** 5 in A:
        b = -b
        break
    b = b + 1

a = int((x + b ** 5) ** 0.2)

print(a, b)

Submission status: Accepted

Solution code:
x=int(input())
s=round(2*abs(x)**(1/5))
for a in range(s,0,-1):
    b=(a**5-x)
    if b<0:
        b=-(round(abs(b)**(1/5),7))
        if b.is_integer():
            b=int(b)
            print("{} {}".format(a,b))
            exit()

    else:
        b=(round(abs(b)**(1/5),7))
        if b.is_integer():
            b=int(b)
            print("{} {}".format(a,b))
            exit()

#

Submission status: Accepted

Solution code:
import numpy as np
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

if __name__ == "__main__":
    X = int(input())
    divs = make_divisors(X)
    #print(divs)
    a = 0
    while True:
        for d in divs:
            b_p = 0
            b_n = 0
            while True:
                b_p += d
                b_n -= d
                #print(b_p)
                if a**5 - b_p**5 == X:
                    #print(a)
                    #print(b_p)
                    print(a,b_p)
                    #print("{} {}".format(int(a), int(b_p)))
                    sys.exit()
                if a**5 - b_n**5 == X:
                    #print("{} {}".format(int(a), int(b_n)))
                    print(a,b_n)
                    sys.exit()
                if b_p > a:
                    #print('break')
                    break
        a += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
x = int(input())
y = []
for i in range(1000):
    y.append(i**5)
for j in range(1000):
    for k in range(j,1000):
        if y[k]+ y[j] == x:
            a = k
            b = -j 
        if y[k] - y [j] == x:
            a = k
            b = j
            
print(a,b)

Submission status: Accepted

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

  for b in range(-200, 200):
    for a in range(-200, 200):
      if (a**5 - b**5 == x):
        print("{0} {1}".format(a, b))
        return 0
      
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import math
 
def f(a, b):
    return a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4

def ihate(x):
    sq = int(math.sqrt(x)) + 1
    facts = []
    for i in range(1, sq):
        if x % i == 0:
            facts.append(i)
 
    for fa in facts:
        d = x // fa
        for a, b in zip(range(-fa, 2000), range(0, 2000+fa)):
            if f(a, b) == d:
                return f'{a} {b}' if a > b else f'{b} {a}'
x = int(input())
print(ihate(x))

Submission status: Accepted

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""


sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    x = int(input())
    for a in range(0, 10000):
        for b in range(-1000, 1000):
            if a**5 - b ** 5 == x:
                print(a, b)
                sys.exit()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = int(input())

ichi = str(x)
ichi = int(ichi[-1])

for i in range(1000):
  test = -(ichi - i)
  for j in range(100):
    for k in range(100):
#      print(test+j*10, i+k*10)
      if test+j*10**5 - i+k*10**5 == x:
        print(test+j*10, i+k*10)
        break
      elif (-1*test+j*10)**5 - (-1*i+k*10)**5 == x:
        print(-1*test+j*10, -1*i+k*10)
        break
    else:
      continue
    break
  else:
    continue
  break

Submission status: Accepted

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

for s in range(1, int(math.sqrt(x))+1):
    if x % s == 0:
        t = x // s
        #print(s, t)
        for b in range(-1000, 1000):
            if (b+s)**5 - b**5 == x:
                print(b+s, b)
                sys.exit(0)
            elif (b+t)**5 - b**5 == x:
                print(b+t, b)
                sys.exit(0)

Submission status: Accepted

Solution code:
x = int(input())

for i in range(-1000, 1000):
    flag = False
    for j in range(-1000, 1000):
        tmp = i ** 5 - j ** 5
        if tmp == x:
            print('{} {}'.format(i, j))
            flag = True
            break
    if flag:
        break

Submission status: Accepted

Solution code:
x = int(input())
a,b = 0,0
#check = 0
for i in range(500):
    #if check==1:
        #break
    for j in range(500):
        if i**5 - j**5 == x:
            a,b = i,j
            #check = 1
            break
        elif i**5 + j**5 == x:
            a,b = i,-j
            #check = 1
            break
        
print(a,b)

Submission status: Accepted

Solution code:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))


X = INT()

def f(a, b):
    return a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4

for alpha in range(1, int(X**0.5)+1):
    if X % alpha == 0:
        beta = X // alpha

        a = alpha // 2
        b = a - alpha

        while f(a, b) <= beta:
            if f(a, b) == beta:
                break
            a += 1
            b += 1
        
        else:
            continue
        break

print(a, b)

Submission status: Accepted

Solution code:
x=int(input())
ans=[]
for a in range(500,-500,-1):
  for b in range(500,-500,-1):
    if a**5-b**5 == x:
      ans.append(a)
      ans.append(b)
      print(*ans)
      exit()
ans = 0
for o in w:
  if o == 1:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
X=int(input())


pow5=[i**5 for i in range(-1000,1001)]
for i,a5 in enumerate(pow5):
    for j,b5 in enumerate(pow5):
        if a5 - b5 == X:
            print(-1000+i,-1000+j)
            exit()

Submission status: Accepted

Solution code:
import math

gojou = [[0] for i in range(2)];

x = int(input());

for i in range(1,129) :
    gojou[0].append(i);
    gojou[1].append(i**5);
    gojou[0].append(-i)
    gojou[1].append((-i)**5);

for i in range(len(gojou[0])) :
    for j in range(len(gojou[0])) :
        if gojou[1][i] - gojou[1][j] == x :
            print(gojou[0][i],gojou[0][j]);
            break;
    else :
        continue;
    break;

Submission status: Accepted

Solution code:
def solve(x):
    to_the_fifth = [x**5 for x in range(150)]
    ttf_set = set(to_the_fifth)
    for i, item in enumerate(to_the_fifth):
        if abs(x-item) in ttf_set:
            # (1-33)**0.2 is a complex number for some reason
            # but -32**0.2 is -2
            second_number_hack = abs(item-x)**0.2
            second_number_hack *= -1 if item-x < 0 else 1
            return map(int, [item**0.2, second_number_hack])
    raise Exception("should've found it")


if __name__ == "__main__":
    print(" ".join(map(str, solve(int(input())))))

Submission status: Accepted

Solution code:
X=int(input())

def ok(B):
    i=1
    B=abs(B)
    while i**5<B:
        i+=1
    return i**5==B

def get(B):
    f = B/abs(B)
    i=1
    B=abs(B)
    while i**5<B:
        i+=1
    return int(i*f)



A_cand=[]
i=0
while i**5<=10**10:
    A_cand.append(i)
    i+=1

#print(A_cand)
for a in range(300):
    B_5=a**5-X
    if ok(B_5):
        r=get(B_5)
        print(a,r)
        exit()
        break

Submission status: Accepted

Solution code:
x = int(input())

break_loop = False
for a in list(map(lambda x: x-64, list(range(200)))):
    for b in list(map(lambda x: x-64, list(range(200)))):
        ans = (a-b)*(a**4 + (a**3)*b + a*a*b*b + a*(b**3) + b**4)
        if x == ans:
            break_loop = True
            print(a,b)
            break
    if break_loop:
        break