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: Time Limit Exceeded

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

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

divs = make_divisors(X)
ans = 0
for div in divs:
  a = -div-100
  b = -100
  while f(a, b) < X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
  a = -100
  b = -div-100
  while f(a, b) > X and b < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
    
print(ans[0], ans[1])

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
ans1=0
ans2=0
for a in range(-(10**10),10**10):
    for b in range(-(10**10),10**10):
        if a**5-b**5==X:
            ans1=a
            ans2=b
            break
print(ans1,ans2)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
a=0
b=0
y=0
yy = 0
z=0
m=0

while True:
    if x == 0:
        break
    for a in range(1,10**9,1):
        y=a**5
        yy=(a+1)**5
        z=x-y
        z*=-1
        if z == 0:
            b = 0
            break
        if z < 0 and x<yy:
            for b in range(-1,-10**9,-1):
                m=z-b**5
                if z-b**5 == 0:
                    break
            else:
                continue
            break
        elif z > 0 and x<yy:
            for b in range(1,10**9,1):
                if z-b**5 == 0:
                    break
            else:
                continue
            break
    else:
        continue
    break

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

x = int(input())
t = x**(1/5)
if isinstance(t, complex):
    y = ceil(t.real)
else:
    y = ceil(t)
cnt = 0
if y == floor(t):
    print(y, 0)
    sys.exit()
b = 0
while True:
    for a in range(y - cnt, y + cnt + 1):
        a5 = a**5
        t = (a5 - x)**(1/5)
        if isinstance(t, complex):
            b = ceil(t.real)
        else:
            b = ceil(t)

        if a5 - b**5 == x:
            print(a, b)
            sys.exit()
        if a5 - (b*-1)**5 == x:
            print(a, b*-1)
            sys.exit()
        b -= 1
        if a5 - b**5 == x:
            print(a, b)
            sys.exit()
        if a5 - (b*-1)**5 == x:
            print(a, b*-1)
            sys.exit()
    cnt += 1

Submission status: Time Limit Exceeded

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions


def show_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


t = int(stdin.readline().rstrip())
data = show_divisors(t)
a = 0
b = 0
while True:
    if t - a > 0:
        while True:
            if a ** 5 + b ** 5 > t:
                break
            if a ** 5 + b ** 5 == t:
                print(str(a) + ' ' + str(-b))
                exit()
                break
            b += 1
    b = 0
    if t - a < 0:
        while True:
            if a ** 5 - b ** 5 > t:
                break
            if a ** 5 - b ** 5 == t:
                print(str(a) + ' ' + str(b))
                exit()
                break
            b += 1
    b = 0
    a += 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

i = 0
ii = 0
flag = False

while not i**5 - -(ii**5) == n:
    if i**5 > n and flag == False:
        i -= 1
        flag = True
    if flag == False:
        i+=1
    if flag == True:
        ii+= 1

print(i,-ii)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

a = int(x**(1/5))
b = -150

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

if flag == 0:
    b = 0
    for i in range(a,a-3000):
        for j in range(b,b-3000):
            if i**5 - j**5 == x:
                print(i,j)
                break

Submission status: Time Limit Exceeded

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

def make_divisors(n):
    divisors = []
    for i in range(1, abs(n)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


if x == 1:
    print('0 -1')
else:
    l = make_divisors(x)
    for m in l:
        r = int(x/m)
        M = m**4 - r
        if M % 5 == 0:
            l2 = make_divisors(int(-M/5))
            for n in l2:
                k = int(M / (-5*n))
                if k - m**2 == n:
                    l3 = make_divisors(n)
                    for a in l3:
                        b = int(n/a)
                        if a-b == m:
                            print(a, end=' ')
                            print(b)
                            exit()

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

x = int(input())
t = x**(1/5)
if isinstance(t, complex):
    y = ceil(t.real)
else:
    y = ceil(t)
cnt = 0
if y == floor(t):
    print(y, 0)
    sys.exit()
b = 0
while True:
    for a in range(y - cnt, y + cnt + 1):
        a5 = a**5
        t = (a5 - x)**(1/5)
        if isinstance(t, complex):
            b = ceil(t.real)
        else:
            b = ceil(t)

        if a5 - b**5 == x:
            print(a, b)
            sys.exit()
        if a5 - (b*-1)**5 == x:
            print(a, b*-1)
            sys.exit()
    cnt += 1

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

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

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
if x == 1:
  print(0,-1)
  exit()
  
def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

c = []
fct = factorize(x)
for div in divisorize(fct):
    c.append(num(div))
    
chk = False
for s in c:
  if chk:
    break
  for i in range(1000):
    if (i+s)**5-i**5 > x:
      break
    if (i+s)**5-i**5 == x:
      ans = (i+s,i)
      chk = True
      break
  if s <1000:    
    for p in range(s,1000):
      j = -1*p
      #print(s,(j+s)**5-j**5)
      if (j+s)**5-j**5 > x:
        break 
      if (j+s)**5-j**5 == x:
        ans = (j+s,j)
        chk = True
        break 
  for ww in range(1,(s+1)//2):
    jj = -1*ww
    if (jj+s)**5-jj**5 == x:
      ans = (jj+s,jj)
      chk = True
      break 
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal
X= int(input())

B=X**(1/5)
while True:
    print(B)
    A= Decimal((X+B**5)**(1/5))
    
    if int(A)==A and A>B:
        print(A,B)
        break
    else:
        B=B+1

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 標準入力の取得
X = int(input())

# 求解処理


def get_B(A: int):
    return - 1 * (X - A ** 5) ** (1 / 5)


def main():
    A = 0
    while True:
        B = get_B(A)
        if (B.imag == 0) and (B.is_integer()):
            break
        A += 1

    result = f"{int(A)} {int(B)}"

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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
X = int(input())
data = make_divisors(X)
for i in data:
  b=int((X/i/4)**0.25)
  while (b+i)**4 <= X/i :
    if (b+i)**5 - b**5 == X:
      print(b+i,b)
      exit(0)
    else:
      b +=1
  b=-1
  while b+i > i/2:
    if (b+i)**5 - b**5 == X:
      print(b+i,b)
      exit(0)
    else:
      b -=1

Submission status: Time Limit Exceeded

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

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

divs = make_divisors(X)
ans = 0
for div in divs:
  a = -div-100
  b = -100
  while f(a, b) < X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
  a = -100
  b = -div-100
  while f(a, b) > X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
    
print(ans[0], ans[1])

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


for number in factorization(x):
  for a in range(number[0]**5):
    b = a - number[0]
    if a**5 - b**5 == x:
      print(a,b)
      break
    elif a**5 - (-b)**5==x:
      print(a,-b)
      break

Submission status: Time Limit Exceeded

Solution code:
import sys



X = int(sys.stdin.readline().rstrip())
Y = [i ** 5 for i in range(X + 1)]

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

def check(d):
    for a in range(1, d // 2 + 1):
        b = a - d
        a5 = Y[a]
        b5 = Y[b] if b >= 0 else -Y[-b]
        if a5 == b5 + X:
            print(a, b)
            sys.exit()


for i in range(1, int(X**0.5)+1):
    if X % i == 0:
        check(i)
        if i != X // i:
            check(X//i)

Submission status: Time Limit Exceeded

Solution code:
#import numpy as np#not for pypy

def main():
    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")
    #second_input = input().split(" ")

    X = first_input[0]
    B = -int(X**(1/5)+1)
    while True:
        B5 = B**5
        if X+B5<0:
            B = B+1
            continue
        A_principle = (X+B5)**(1/5)
        if (A_principle-(A_principle//1))==0:
            print(str(int(A_principle))+" "+str(B))
            break
        B = B+3

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def factorization(num):
  if num == 1:
    return [1]
  factor = []
  while num > 1:
    for i in range(num - 1):
      k = i + 2
      if num % k == 0:
        factor.append(k)
        num = int(num / k)
        break
  return factor
  
x=int(input())
a=0
b=0
a_b=0
y=factorization(x)
len_y=len(y)
z=set(y)


z=list(z)
#print(z)
for j in range(len(z)):
  a_b=z[j]
  for k in range(a_b):
    a=a_b+k
    b=k
    if a**5-b**5== x:
      print("%d %d" % (a,b))
      exit()
    a=a_b-k
    b=0-k
    if a**5-b**5== x:
      print("%d %d" % (a,b))
      exit()
      
if len_y > 2:
  z=set([])
  for l in range(0,len_y-1):
    for m in range(l,len_y):
      z=z|set([y[l]*y[m]])
  z=list(z)
  for j in range(len(z)):
    a_b=z[j]
    for k in range(a_b):
      a=a_b+k
      b=k
      if a**5-b**5== x:
        print("%d %d" % (a,b))
        exit()
      a=a_b-k
      b=0-k
      if a**5-b**5== x:
        print("%d %d" % (a,b))
        exit()
    
if len_y > 3:
  z=set([])
  for l in range(0,len_y-2):
    for m in range(l,len_y-1):
      for n in range(m,len_y):
        z=z|set([y[l]*y[m]*y[n]])
  z=list(z)
  for j in range(len(z)):
    a_b=z[j]
    for k in range(a_b):
      a=a_b+k
      b=k
      if a**5-b**5== x:
        print("%d %d" % (a,b))
        exit()
      a=a_b-k
      b=0-k
      if a**5-b**5== x:
        print("%d %d" % (a,b))
        exit()

if len_y > 4:
  z=set([])
  for l in range(0,len_y-3):
    for m in range(l,len_y-2):
      for n in range(m,len_y-1):
        for p in range(n,len_y):
          z=z|set([y[l]*y[m]*y[p]])
  z=list(z)
  for j in range(len(z)):
    a_b=z[j]
    for k in range(a_b):
      a=a_b+k
      b=k
      if a**5-b**5== x:
        print("%d %d" % (a,b))
        exit()
      a=a_b-k
      b=0-k
      if a**5-b**5== x:
        print("%d %d" % (a,b))
        exit()

if len_y > 5:
  z=set([])
  for l in range(0,len_y-4):
    for m in range(l,len_y-3):
      for n in range(m,len_y-2):
        for p in range(n,len_y-1):
          for q in range(p,len_y):
            z=z|set([y[l]*y[m]*y[p]*y[q]])
  z=list(z)
  for j in range(len(z)):
    a_b=z[j]
    for k in range(a_b):
      a=a_b+k
      b=k
      if a**5-b**5== x:
        print("%d %d" % (a,b))
        exit()
      a=a_b-k
      b=0-k
      if a**5-b**5== x:
        print("%d %d" % (a,b))
        exit()

Submission status: Time Limit Exceeded

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
X = int(input())
A = []
for i in factorization(X):
  for j in range(0,i[1]+1):
    a = i[0]**j
    b = X//a
    if(a<b):
      A.append([a,b])
    else:
      A.append([b,a])
 
A = list(map(list, set(map(tuple, A))))
flag = 0
for i in A:
  r = list(range(0,1000000+1))
  for a in r:
    b = a - i[0]
    if a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4 == i[1]:
      print(a,b)
      flag = 1
      break
  if flag==1:
    break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
b =1
while True:
    b_5 = b**5
    a =(x+b_5)**(1/5)
    if a.is_integer:
        print(a,b)
    b +=1

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
for i in range(-10,1000,1):
    for j in range(-10,10000,1):
        if a == ((i**5) - (j**5)):
            print(i, j)
            break;
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
 
X = int(input())

A_max = 0
abs_X = abs(X)
cnt = 0

while 1:
  if ( cnt**5 >= abs_X ):
    cnt += 1
    A_max = i
    break

print(A_max)
B_max = A_max

for i in range(0, A_max+1):
  for j in range(0, B_max+1):
    
    A = i**5
    B = j**5
    
    if ( A+B==X or A-B==X or -A+B==X or -A-B==X ):
      print(i,j)
      break
  
  else:
    continue
  break

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
flag=True
l=[]
for i in range(2,int(x**0.5)+1):
  if x%i==0:
    l.append(i)
    #print(q)
while flag:
  for i in range(-100,100):
    for j in l:
      if (i+j)**5-i**5==x:
        flag=False
        a=i+j
        b=i
print(a,b)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
for i in range(1,int(x**(1/2))+1):
    if x%i:continue

    ar,s=i,x//i
    pre=[]
    if pow(ar,5,5)==x%5:pre.append(ar)
    if  pow(s,5,5)==x%5:pre.append(s)

    for a in set(pre):
        d=(x-a**5)//5//a
        if d==0:print(a,0);exit()
        for b in range(1,int(abs(d)**(1/2))+1):
            if d%b:continue
            if (a+b)**5-b**5==x:
                print(a+b,b);exit()
            if (a-b)**5+b**5==x:print(a-b,-b);exit()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

a = int(pow(x, 1/5))

while True:
    if pow(a,5)-x<0:
      b = -int(pow(-(a**5-x), 1/5))
    else:
      b = int(pow((a**5-x), 1/5))
      
    if pow(a,5)-pow(b,5)==x:
      break
    a += 1

print(a, b)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A = int(X/2)
while True:
    diff = X - A**5
    if diff < 0:
        minus_flg = False
        diff = abs(diff)
    else:
        minus_flg = True
    B = pow(diff, 0.2)
    if (isinstance(B, float)) and B.is_integer():
        break
        A += 1
if minus_flg:
    B = int(B)*-1
print(A, int(B))

Submission status: Time Limit Exceeded

Solution code:
def fifthRoot(y):
  yy=y
  s=1
  if y<0:
    yy=-y
    s=-1
  l=0
  r=yy
  while True:
    m=(l+r)//2
    if l**5==yy:
      return s*l
    if r**5==yy:
      return s*r
    if m**5==yy:
      return s*m
    if m**5>yy:
      r=m
    else:
      l=m
    if l==m or r==m:
      return
def main():
  x=int(input())
  for i in range(10**9):
    y=fifthRoot(x-i**5)
    if y is not None:
      return (i,-y)
    y=fifthRoot(x+i**5)
    if y is not None:
      return (-i,-y)
print(*main())

Submission status: Time Limit Exceeded

Solution code:
def f(x):
    for n in range(1, x + 1):
        if x % n == 0:
            for a in range(n * 2):
                b = a - n
                if a ** 5 - b ** 5 == x:
                    return a, b


x = int(input())
a, b = f(x)
print(a, b)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
flag = 0
for s in range(1,X+1):
  if X%s == 0:
    for a in range(0, X):
      b = a - s
      t = a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4
      bb = -a - s
      t2 = a**4 - a**3*bb + a**2*bb**2 - a*bb**3 + bb**4
      if s*t == X:
        print(a,b)
        flag=1
        break
      if s*t2 == X:
        print(-a,bb)
        flag=1
        break
  if flag==1:
    break

Submission status: Time Limit Exceeded

Solution code:
from math import pow, floor, log


def root5(x):
    if x == 0 or x == -1 or x == 1:
        return x
    return pow(x, 1.0/5)


x = int(input())
b = -1
while True:
    a = x + (b ** 5)
    temp_a = root5(a)
    a = floor(root5(a))
    b = floor(root5(b))
    if pow(a, 5) - pow(b, 5) == x:
        print("{} {}".format(a, b))
        break
    b += 1

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

x = load()
for b in range(-1, -1000000000, -1):
    b5 = b ** 5
    y = (x + b5)**(1/5)
    if type(y) == complex:
        continue
    if abs(y - math.floor(y)) < 0.000005:
        print(math.floor(y), b)
        exit()

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
for B in range(-10**6,10**6):
    if type((X+B**5)**0.2)!=complex:
        if (X+B**5)**0.2==int((X+B**5)**0.2):
            print(int((X+B**5)**0.2), B)
            break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
for b in range(1,10**100):
    if (x + b**5)**(1/5) == int((x + b**5)**(1/5)):
        c = b
        a = int((x+b**5)**(1/5))
        break

print(f"{a} {c}")

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

X_kok = X ** (1/5)
X_kok_tamsayi = int(X_kok) // 1
# ikisi de 0 dan buyuk

for i in range(X_kok_tamsayi-1, X):
  for j in range(X_kok_tamsayi+1, 0, -1):
    if (i ** 5) - (j ** 5) == X:
      print(i, j)
      exit()
for i in range(0, X_kok_tamsayi):
  for j in range(-1*X_kok_tamsayi, 0, 1):
    if (i ** 5) - (j ** 5) == X:
      print(i, j)
      exit()

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
flag=True
l=[]
for i in range(2,int(x**0.5)+1):
  if x%i==0:
    l.append(i)
    #print(q)
while flag:
  for i in range(-100000,100000):
    for j in l:
      if (i+j)**5-i**5==x:
        flag=False
        a=i+j
        b=i
print(a,b)

Submission status: Time Limit Exceeded

Solution code:
def DI(n):
    D = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            D.append(i)
            if i != n//i:
                D.append(n//i)
    return D
X = int(input())
D = DI(X)
flag = False
for i in range(len(D)):
    for a in range((D[i]+1)//2):
        b = -(D[i] - a)
        if a**5 - b**5 == X:
            print(str(a) + ' ' + str(b))
            flag = True
            break
    if flag:
        break

Submission status: Time Limit Exceeded

Solution code:
import sys
readline = sys.stdin.buffer.readline
x =int(readline().rstrip().decode())
b = -1
for i in range(1000000000):
  if x == i**5 - b**5:
    print(str(i) +" "+ str(b))
    break

Submission status: Time Limit Exceeded

Solution code:
import collections
import itertools

X = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a = prime_factorize(X)
L = len(a)

for i in range(L+1):
    d = itertools.combinations(a,i)
    Y = 1
    if i != 0:
        for j in d:
            Y *= j[0]
    A = -X
    while A < X+1:
        if A ** 5 - (A-Y)**5 == X:
            print(A,A-Y)
            exit()
        else:
            A += 1

Submission status: Time Limit Exceeded

Solution code:
import math

x_str = input()
x = int(x_str)

power_five_list = []

a = 0
b = 0

while True:
    a_power_five = int(math.pow(a, 5))
    b_power_five = int(math.pow(b, 5))

    if a_power_five - b_power_five < x:
        a += 1
    if a_power_five - b_power_five == x:
        print("{0} {1}".format(a, b))
        exit(0)
    if a_power_five - b_power_five > x:
        break

while True:
    a_power_five = int(math.pow(a, 5))
    b_power_five = int(math.pow(b, 5))

    if a_power_five - b_power_five > x:
        b += 1
    if a_power_five - b_power_five == x:
        print("{0} {1}".format(a, b))
        exit(0)
    if a_power_five - b_power_five < x:
        break

while True:
    a -= 1

    for i in reversed(range(b+1)):

        a_power_five = int(math.pow(a, 5))
        b_power_five = int(math.pow(i, 5))

        if a_power_five - b_power_five == x:
            print("{0} {1}".format(a, i))
            exit(0)
        if a_power_five + b_power_five == x:
            print("{0} {1}".format(a, -1*i))
            exit(0)
        if - a_power_five - b_power_five == x:
            print("{0} {1}".format(-1*a, i))
            exit(0)
        if - a_power_five + b_power_five == x:
            print("{0} {1}".format(-1*a, -1*i))
            exit(0)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
for B in range(X + 1):
    p_A = (B ** 5 + X) ** (1 / 5)
    n_A = ((-1 * B) ** 5 + X) ** (1 / 5)
    if isinstance(p_A, complex) == False and isinstance(n_A, complex) == False:
        if int(p_A) ** 5 - B ** 5 == X:
            print(int(p_A), B)
            break
        if int(n_A) ** 5 - (-1 * B) ** 5 == X:
            print(int(n_A), -1 * B)
            break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A = int(pow(X, 0.5))
while True:
    diff = X - A**5
    if diff < 0:
        minus_flg = False
        diff = abs(diff)
    else:
        minus_flg = True
    B = pow(diff, 0.2)
    if (isinstance(B, float)) and B.is_integer():
        break
        A += 1
if minus_flg:
    B = int(B)*-1
print(A, int(B))

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

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

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
#print(X)
n = X
div = []
for i in range(1, int(n**0.5)+1):
  if n % i == 0:
    div.append(i)
    if i != n // i:
      div.append(n//i)
#print(div)

for i in div:
  for a in range(-i, i+1): 
    b = a - i
    #print(a, b)
    if a**5 - b**5 == X:
      print(a, b)
      break
  else:
    continue
  break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
a, b = 0, 0
nx = 'a'
while True:
    if a ** 5 - b ** 5 == x:
        print('{} {}'.format(a, b))
        break
    if -a ** 5 - b ** 5 == x:
        print('{} {}'.format(-a, b))
        break
    if a ** 5 - (-b) ** 5 == x:
        print('{} {}'.format(a, -b))
        break
    if -a ** 5 - (-b) ** 5 == x:
        print('{} {}'.format(-a, -b))
        break
    if nx == 'a':
        a += 1
        nx = 'b'
    else:
        b += 1
        nx = 'a'

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

def bin_s(l, r, a):
    while l <= r:
        mid = l + r // 2
        if a ** 5 - mid ** 5 == x:
            return (mid, True)
        elif a ** 5 - mid ** 5 > x:
            l = mid + 1
        else:
            r = mid - 1
    return (-1, False)

def search(x: int) -> (int, int):
    a = 1
    while True:
        if a ** 5 - (a - 1)** 5 <= x <= a ** 5 + (a - 1)** 5:
            b, j = bin_s(-a + 1, a - 1, a)
            if j:
                return (a, b)
        a += 1

a, b = search(x)
print(f"{a} {b}")

Submission status: Time Limit Exceeded

Solution code:


def sovle_odd(X):
    max = 3000
    for A in range(1,max, 2):
        for B in range(max):
            AX = A*A*A*A*A
            BX = B*B*B*B*B

            C = AX-BX
            #if AX-BX == X:
            if C == X:
                print(A, B)
                return
            #if BX-AX == X:
            if -C == X:
                print(B, A)
                return
            C = -AX - BX
            #if -AX - BX:
            if C == X:
                print(-A, B)
                return
            #if AX + BX:
            if -C == X:
                print(A, -B)
                return

def solve_even(X):
    max = 5000
    for A in range(0,max, 2):
        for B in range(0, max, 2):
            AX = A*A*A*A*A
            BX = B*B*B*B*B

            C = AX-BX
            if C == X:
                print(A,B)
                return
            elif -C == X:
                print(B,A)
                return
            
            C = -AX - BX
            if C==X:
                print(-A,B)
                return
            elif -C==X:
                print(A, -B)
                return

def solve():
    X = int(input())
    
    if X%2==1: # X odd case
        sovle_odd(X)
    else: # X even case
        solve_even(X)

solve()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
#n, k = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
#a = 0
#b = 0
for a in range(0, x+1):
    for b in range(0, x+1):
        if pow(a, 5)-pow(b, 5) == x:
            print(a, end=" ")
            print(b)
            exit()
        elif pow(a, 5)-pow(b*-1, 5) == x:
            print(a, end=" ")
            print(b*-1)
            exit()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A = 1
K = 1
while K < X:
    A += 1
    K = A ** 5
S = A - 4
w = 0
while w != 1:
    Q = S ** 5 - X
    if Q < 0:
        B = 0
        while (Q < B**5):
            B -= 1
        if (Q == B**5):
            w += 1
        else:
            S += 1
        
    elif Q > 0:
        B = 0
        while (Q > B**5):
            B += 1
        if (Q == B**5):
            w += 1
        else:
            S += 1
    else:
        B = 0
print(S,B)