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:
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

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

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

X = input_int()

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

A_B = prime_factorize(X)
A_B_other = X // A_B
A = -120
while True:
    B = A - A_B

    if A ** 5 - B ** 5 == X:
        print(A, int(B))
        exit()
    B = A - A_B_other

    if A ** 5 - B ** 5 == X:
        print(A, int(B))
        exit()

    A += 1

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
a = 1
flug = True
while flug:
    b = -119
    while b <= 118:
        if a ** 5 - b ** 5 == X:
            print(a, b)
            flug = False
            break
        else:
            b += 1

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

def f(x,b):
    return int((x+b**5)**(1/5))

b=0
plus=1
while True:
    ans = f(x,b)
    #print(ans)
    if ans**5-b**5 == x:
        print(ans, b)
        break
    elif plus == 1:
        b=b*(-1)
        plus = 0
    elif plus == 0:
        b=b*(-1)
        b+=1

Submission status: Time Limit Exceeded

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

B=1
b=0
while True:
    
    print(b)
    
    a= Decimal((X+b**5)**(1/5))
   
    if int(a)==a and a>b:
        print(a,b)
        break
    else:
        if X+(b-1)**5<0:
            break
        else:
            b=b-1
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:
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)

a.append(1)
a=list(set(a))
le=len(a)
for i in range(le):
    if a[i]>11:
        a[i]=0
a=list(set(a))

len=len(a)
t=max(a)*(-1)
ansx=0
ansy=0
while True:
    if not ansx== 0 or not ansy== 0:
        break

    for i in range(len):
        if ((t+a[i])**5-t**5)-x==0:
            ansx=t+a[i]
            ansy=t
            break
        else:
            t+=1
print(ansx,ansy)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
x_mod = x % 5
i = -200
while True:
    if i - (i - x_mod) == x_mod and i ** 5 - (i-x_mod)**5 == x:
        print(i, i-x_mod)
        break
    i += 1

Submission status: Time Limit Exceeded

Solution code:
# 競プロの数学は高校数学みたいな泥臭いのが多い
# めんどくさがってA,Bの範囲を計算しなかったのが原因
# なんなら大雑把にみて -1000~1000でもいけてる
X = int(input())
for i in range(2000):
    for j in range(2000):
        a = i-1000
        b = j-1000
        if X == a**5-b**5:
            print(a, end=" ")
            print(b)
            break

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

for i in range(-1*N,N):
    for j in range(-1*N,N):
        if i**5 - j**5 == N:
            print(i,j)
            quit()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
import sys
input = sys.stdin.readline


x = int(input().strip())
abs_x = abs(x)

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

def X_plus(a, b):
    return a**5 + b**5

a = 2
b = 1

while True:
    #print(a, b)
    if X(a, b) == abs_x:
        if x < 0:
            a = -a
            b = -b
        print(a,b)
        exit()

    if (a-b) > 1:
        b += 1
    elif a-b == 1:
        if X(a, b) < abs_x:
            a += 1
        else:
            #print("引き算では無理")
            break
    else:
        print("Error")
        exit()

#print("足し算を判定")

a = 0
b = 0

while True:
    if X_plus(a, b) == abs_x:
        b = -b
        if x < 0:
            a = -a
            b = -b
        print(a, b)
        exit()

    if X_plus(a+1, b) <= abs_x:
        a += 1
        b = 0
    else:
        if X_plus(a, b+1) <= abs_x:
            b += 1
        else:
            a -= 1
            b -= 1

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left

x = int(input())
kouho = [pow(i, 5) for i in range(10 ** 7)]

for left in range(10 ** 7):
    L = pow(left, 5)
    kouho1 = abs(L + x)
    pos1 = bisect_left(kouho, kouho1)
    if pos1 < 10 ** 7:
        if kouho[pos1] == kouho1:
            right = pos1
            break
    kouho2 = abs(L - x)
    pos2 = bisect_left(kouho, kouho2)
    if kouho[pos2] < 10 ** 7:
        if kouho[pos2] == kouho2:
            right = pos2
            break

bigger = max(abs(left), abs(right))
smaller = min(abs(right), abs(left))
if smaller == 0:
    print(bigger, smaller)
    exit()
if bigger ** 5 - smaller ** 5 == x:
    print(bigger, smaller)
if bigger ** 5 + smaller ** 5 == x:
    print(bigger, -smaller)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

for a in range(10**4):
    for b in range(10**4):
        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:
from collections import deque
import sys
input = sys.stdin.readline


x = int(input().strip())
abs_x = abs(x)

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

def X_plus(a, b):
    return a**5 + b**5

a = 2
b = 1

while True:
    #print(a, b)
    if X(a, b) == abs_x:
        if x < 0:
            a = -a
            b = -b
        print(a,b)
        exit()

    if (a-b) > 1:
        b += 1
    elif a-b == 1:
        if X(a, b) < abs_x:
            a += 1
        else:
            #print("引き算では無理")
            break
    else:
        print("Error")
        exit()

#print("足し算を判定")

a = 0
b = 0

while True:
    if X_plus(a, b) == abs_x:
        b = -b
        if x < 0:
            a = -a
            b = -b
        print(a, b)
        exit()

    if X_plus(a+1, b) <= abs_x:
        a += 1
        b = 0
    else:
        if X_plus(a, b+1) <= abs_x:
            b += 1
        else:
            a -= 1
            b = 0

Submission status: Time Limit Exceeded

Solution code:

X = int(input())

def gen_divisor(x):
    for i in range(x, 0, -1):
        if x % i == 0:
            yield i

def gen_candidates(divisor):
    a = -119
    while True:
        a = a + 1
        b = a - divisor
        tmp = a**5 - b**5
        if  tmp == X:
            yield (a, b)
        if a >= 120:
            break


for divisor in gen_divisor(X):
    for a, b in gen_candidates(divisor):
        print(a,b)
        break
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

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

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 solve(num, X):
    a = 1
    for i in range(1, X+1):
        if (i * 100) ** 5 - (i * 100 - num) ** 5 >= X:
            break
    max_a = 100 * i
    a = max_a - 99
    while a <= max_a:
        if (a) ** 5 - (a -num) ** 5 == X:
            return True, a, a - num
        a += 1
    return False, 0, 0

arr = make_divisors(abs(X))
for num in arr:
    if (num - X) % 5:
        continue
    flag, a, b = solve(num , X)
    if flag:
        print(a, b)
        exit()
    flag, a, b = solve(-num , X)
    if flag:
        print(a, b)
        exit()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
n = 10**7

def blp(dp,num):
    l = 0
    r = len(dp)-1
    while l <= r:
        mid = (l+r)//2
        if num == dp[mid]:return mid
        elif num >= dp[mid]:l = mid+1
        else:r = mid-1
    return 0

def bln(dp,num):
    l = 0
    r = len(dp)-1
    while l>=r:
        mid = (l+r)//2
        if num == dp[mid]:return mid
        elif num >= dp[mid]:r = mid+1
        else:l = mid-1
    return 0
            
ap = [i**5 for i in range(n)]
an = [-(i**5) for i in range(n)]

for b in range(-n,n):
    num = x + b**5
    a = max(blp(ap,num),bln(an,num))
    if a:print(a,b) ; break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

for a in range(-(10**3), 10**3 + 1):
    for b in range(-(10**3), 10**3 + 1):
        if a ** 5 - b ** 5 == x:
            break
        else:
            pass
print("{:0} {:1}".format(a, b))

Submission status: Time Limit Exceeded

Solution code:
import math
x=int(input())
for i in range(1,int(math.sqrt(x)+1)):
    if x % i==0:
        t=i
        w=x//i
        a=0
        while a<=t:
            b=a-t
            if a**5-b**5==x:
                print(a,b)
                exit()
            a+=1
        a = 0
        while a <= w:
            b = a - w
            if a ** 5 - b ** 5 == x:
                print(a, b)
                exit()
            a += 1

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
 
ans = None
 
while ans is None:
  for i in range(119):
    for j in range(119):
      if i ** 5 - j ** 5 == X:
        ans = (i, j)
      elif (i*-1) ** 5 - j ** 5 == X:
        ans = (-i, j)
      elif i ** 5 - (j*-1) ** 5 == X:
        ans = (i, -j)
print(ans[0],ans[1])

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
for i in range(-3000, 3000):
    for j in range(-3000, 3000):
        if X == (i**5-j**5):
            print(i, j)
            break

Submission status: Time Limit Exceeded

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



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

def main():
    X = int(input())
    divs = make_divisors(X)
    for d in divs:
        tm = X-pow(d,5)
        if tm%10!=0:
            continue
        divss = make_divisors(abs(tm)//(5*d))
        divss += [0]
        for b in divss:
            Y=pow(b+d,5)-pow(b,5)
            Y_=pow(-b+d,5)-pow(-b,5)
            if Y==X:
                print(b+d,b)
                sys.exit()
            elif Y_==X:
                print(-b+d,-b)
                sys.exit()

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import math
def main():
# 整数の入力
    x = int(input())
    a = 0
    b = 0
    while True:
        y = 0
        y5_x = math.pow(b, 5)
        y = math.pow(y5_x - x, -5)
        
        y = int(y)
        if math.pow(y, 5) + x == y5_x:
            a = y
            break
        else:
            b += 1

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

a = 1
b = 0

while a ** 5 <= x:
    a += 1
if x >= a ** 5 - (a - 1) ** 5:
    is_pos = True
else:
    is_pos = False
    a -= 1

tmp = 1 if is_pos else -1

while a ** 5 - b ** 5 != x:
    b += tmp


print(a, b)

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
num = []
nn = -1

while nn ** 5 < N :
  nn += 1
  A = str(nn ** 5 - N)
  if A in num:
    print(nn, A.index(A))
    exit()
  num.append(str(nn ** 5)) 
  
An = -1
Bn = -1
A = 0
B = 0
while True :
  An += 1
  Bn = An
  A = 0
  B = 0
  while A + B < N :
    Bn += 1
    A = An ** 5
    B = Bn ** 5
    if A + B == N:
      print(An, Bn * -1)
      sys.exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

b = 0
while 1:
    a = (X + b ** 5) ** (1/5)
    if a.is_integer() == True:
        break
    b = -b
    c = X + b ** 5
    if c >= 0:
        a = c ** (1/5)
        if a.is_integer() == True:
            break
    b = -b
    b += 1
print(int(a), b)

Submission status: Time Limit Exceeded

Solution code:
def f(a: int, b: int) -> int:
  return a ** 5 - b ** 5

x = int(input())
factor = []
fact = 1
while fact * fact < x:
  if x % fact == 0:
    factor.append(fact)
    factor.append(x // fact)
  fact += 1
if fact * fact == x:
  factor.append(fact)
for d in factor:
  if x // d % 5 > 1:
    continue
  a = d // 2
  while f(a, a - d) < x:
    a *= 2
  if f(a, a - d) == x:
    print(a, a - d)
    break
  upper = a
  lower = a // 2
  while upper - lower > 1:
    a = (upper + lower) // 2
    value = f(a, a - d)
    if value < x:
      lower = a
    elif value > x:
      upper = a
    else:
      print(a, a - d)
      break
  else:
    if f(lower, lower - d) == x:
      print(lower, lower - d)
    continue
  break

Submission status: Time Limit Exceeded

Solution code:
import math

def main(X):
    end = False
    lst = f(X)
    # print(lst)
    for L in lst:
        if end:
            break
        else:
            for l in L:
                B = 1
                A = B + l[0]
                while g(A, B) > l[1]:
                    if g(A, B) < g(A + 1, B + 1):
                        break
                    B += 1
                    A = B + l[0]
                while g(A, B) <= l[1]:
                    if g(A, B) == l[1]:
                        print(A, B)
                        end = True
                        break
                    B += 1
                    A = B + l[0]
                # ***********************
                if end:
                    break
                else:
                    B = -1
                    A = B + l[0]
                    while g(A, B) > l[1]:
                        if g(A, B) < g(A - 1, B - 1):
                            break
                        B -= 1
                        A = B + l[0]
                    while g(A, B) <= l[1]:
                        if g(A, B) == l[1]:
                            print(A, B)
                            end = True
                            break
                        B -= 1
                        A = B + l[0]
                if end:
                    break


def f(X):
    return [[[X // i, i], [i, X // i]] for i in range(1, math.floor(X ** 0.5) + 1) if X % i == 0]

def g(A, B):
    return (A ** 4) + (A ** 3) * B + (A ** 2) * (B ** 2) + A * (B ** 3) + (B ** 4)



if __name__ == '__main__':
    X = int(input())
    main(X)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

A = 0
B = 0

    # if X == (A - B) * (pow(A,4) + pow(A,3)*B + pow(A,2)*pow(B,2) + a*pow(B,3) + pow(B,4)):
    #     print(str(A) +' '+str(B))

# while

# pow(A,5) - X == pow(B,5)

while B>=0:
    A = (pow(B, 5) + X) ** (1/5)
    if isinstance(A,float) and A.is_integer():
        break

    A = (pow(-1 * B, 5) + X) ** (1/5)
    if isinstance(A,float) and A.is_integer():
        B = -1 * B
        break

    B += 1

print(str(int(A)) + ' ' + str(int(B)))

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())

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

    def calc(a, b):
        ans = 0
        for i in range(0, 5):
            ans += pow(a, i)*pow(b, 4-i)
        return ans

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

    if X % 2 == 0:
        x = 2
    else:
        for x in range(3, int(X**0.5), 2):
            if X % x == 0:
                break

    N = 10**16
    for i in range(N):
        j = i - x

        ij = calc(i, j)
        if x * ij == X:
            print(i, j)
            break




if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
division_list = []
for i in range(1, int(x / 2) + 2):
  if x % i == 0:
    division_list.append(i)
flag = False
#print(division_list)
for i in range(int(x / 2) + 2, (-1) * int(x / 2) - 2, -1):
  for j in division_list:
    if i ** 5 - (i - j) ** 5 == x:
      print(i, i - j)
      flag = True
      break
  if flag:
    break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

y = 1000
s = -1000
t = -1000

a = 0
b = 0

while s < y:
    t = -y
    while t < y:
        if s ** 5 - t ** 5 == x:
            a = int(s)
            b = int(t)
        t += 1
    s += 1

print(a, b)

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
m=0
n=0
w=0
e=1
r=1
if m==0:
  while  n==0:
    u=e**5-w**5
    if u>x:
      w==0
      r+=1
      e=r
    if x==u:
      print(e,end=" ")
      print(w)
      n+=1
    else:
      e+=1
      w+=1

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


x = int(input())
for i in range(-1000,1001):
    for j in range(-1000,1001):
        if i**5 - j**5 == x:
            print(i,j)

Submission status: Time Limit Exceeded

Solution code:
import sys

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


for i in range(len(make_divisors(x))):
    for j in range(180):
        if j ** 5 - (j - make_divisors(x)[i]) ** 5 == x:
            print(j, j - make_divisors(x)[i])
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
from math import pow
from itertools import combinations
x = int(input())

def prime_factorize(n):
    a = [1]
    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

def func(a, b):
    return pow(a, 5) - pow(b,5)
    
cands = prime_factorize(x)
ok = False

for i in range(2 ** len(cands)):
    y = 1
    for j in range(len(cands)):        
        if (i >> j) & 1:
            y *= cands[j]
        for a in range(1, y + 1):
            b = a - y
            if func(a, b) == x:
                print(a, b)
                ok = True
                break
        if ok:
            break
    if ok:
        break

Submission status: Time Limit Exceeded

Solution code:


def sovle_odd(X):
    max = 2000
    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 = 4500
    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:
import math
X=int(input())

A=int(X**(1/5))
Bp=0
Bm=0
for i in range(X):
    if(A**5-Bp**5==X):
        print(A,Bp)
        break
    if(A**5-Bm**5==X):
        print(A,Bm)
        break
    Bp+=1
    Bm-=1

Submission status: Time Limit Exceeded

Solution code:
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

X = intinp()

dict_of_5th_p = dict()

i = 0
while True:
    i_5th_p = i**5
    if i_5th_p > X:
        break
    dict_of_5th_p[i] = i_5th_p
    i += 1
i -= 1

outf = False
while True:
    c = X - i**5
    for j in range(0, i):
        d = j **5
        if c == d:
            ans_A = i
            ans_B = -j
            outf = True
            break
    if outf:
        break
    i -= 1

print(ans_A, ans_B)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
x = 1
while ((x-1)**2)*9 < X:
    x += 1
for i in range(x):
    for j in range(-x, i):
        if i**5-j**5 == X:
            a = [i,j]
            break 
print(*a)

Submission status: Time Limit Exceeded

Solution code:
from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで
 
def check(a,b,X):
  if a**5-b**5 == X:
    return 1
  else:
    return 0
  
X = inp()
A = 0
need = 0
tmp = 0
while 1:
  B = 1
  if A**5>X:
    need = 1
  else:
    need = -1
  reverse = 0
  if check(A,B,X):
    print(str(A)  + " " + str(B))
    break
  else:
    while 1:
      if B < A and A-X <= B:
        if check(A,B,X):
          print(str(A)  + " " + str(B))
          tmp = 1
          break
      else:
        break
      if reverse == 0 and need == -1:
        B = (-1)*B
        reverse = 1
      elif reverse == 1 and need == 1:
        B = (-1)*B
        B = B + 1
        reverse = 0
      elif reverse == 0 and need == 1:
        B = B + 1
      elif reverse == 1 and need == -1:
        B = B -1
  A += 1
  if tmp:
    break

Submission status: Time Limit Exceeded

Solution code:
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)

a.append(1)
a=list(set(a))
len=len(a)
#for i in range(len):
#    if a[i]>11:
#        a[i]=0
#a=list(set(a))

t=-1000000
ansx=0
ansy=0
while True:
    if not ansx== 0 or not ansy== 0:
        break
    for i in range(len):
        if ((t+a[i])**5-t**5)-x==0:
            ansx=t+a[i]
            ansy=t
            break
        else:
            t+=1
print(ansx,ansy)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
for i in range(-2000, 2000):
  for j in range(-2000, 2000):
    if i**5 - j**5 == X:
      print(i, j)
      exit()

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 = 4500
    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())

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)

a.append(1)
a=list(set(a))
len=len(a)
#for i in range(len):
#    if a[i]>11:
#        a[i]=0
#a=list(set(a))

t=max(a)*(-1)
ansx=0
ansy=0
while True:
    if not ansx== 0 or not ansy== 0:
        break
    for i in range(len):
        if ((t+a[i])**5-t**5)-x==0:
            ansx=t+a[i]
            ansy=t
            break
        else:
            t+=1
print(ansx,ansy)

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)
    return divisors

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

divs = make_divisors(X)
ans = 0
for div in divs:
  a = -div-120
  b = -120
  while f(a, b) < X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
  a = -120
  b = -div-120
  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())
a = 0
b = 0

for a_ in range(-1000, 1000):
    for b_ in range(-1000, 1000):
        if a_**5 - b_**5 ==x:
            print(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 = 4500
    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:
import math
X = int(input())
N = math.floor(X ** (1/2)) + 1

for a in range(N):
  for b in range(-N,N):
    x = a**5
    y = b**5
    T = 0
    if x-y == X:
      print(a,b)
      T = 1
      break
  if T == 1:
    break

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+2000):
        for j in range(b,b+2000):
            if i**5 - j**5 == x:
                print(i,j)
                flag = 1
                break

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

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
a = []
b = 0
flag = True
for i in range(1,int(X**(1/5))+1):
  if(X%i== 0):
    a.append(i)
while(flag):
  for i in range(len(a)): 
    if(pow(b+a[i],5)-pow(b,5) == X):
      print("%d %d"%(b+a[i],b))
      flag = False
      break
  b -= 1
  if(-pow(b,5) > X):
    b = int(X**(1/5))

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 = 6000
    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()