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

while True:
    for a in range(100):
        a5 = a**5
        if a5 == x:
            print(a, 0)
            exit()

        for b in range(2, -10, -1):
            b5 = b**5
            if a5 - b5 == x:
                print(a, b)
                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)
        for c in range(b, -1, -1):
            if a5 - c**5 == x:
                print(a, c)
                sys.exit()
            if a5 - (c*-1)**5 == x:
                print(a, c*-1)
                sys.exit()
    cnt += 1

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A = int(pow(X, 0.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:
X=int(input())
i=0
while True:
    b=(i**5-X)**0.2
    if bool(b)==complex:
        i+=1
        continue
    if bool(b)==float:
        if b.is_integer()==True:
            break
        else:
            i+=1
            continue
print(i,end=" ")
print(int(b))

Submission status: Time Limit Exceeded

Solution code:
import math
X = int(input())
A=[]
B=[]
number = []
flag = 0
for i in range(math.ceil(X/10) * -1, math.ceil(X/10) + 1):
    number.append(i)
    A.append(i ** 5)
    B.append(i ** 5)

for i in range(len(A)):
    for j in range(len(B)):
        if(A[i] - B[j] == X and flag == 0):
            print(number[i],number[j])
            flag += 1

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 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**3+2*b*a**2+2*b**2*a+b**3==d//b:
                print(a+b,b);exit()
            if a**3-2*b*a**2+2*b**2*a-b**3==-(d//b):print(a-b,-b);exit()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
ls = []
for i in range(101):
    ls.append(pow(i, 5))

a = 0
while True:
    b = pow(a, 5)-x
    if -b in ls:
        print(a, -ls.index(-b))
        break
    if b in ls:
        print(a, ls.index(b))
        break
    a += 1

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 +(b+i)**3*b+((b+i)*b)**2+(b+i)*b**3 + b**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:
import numpy as np
import sys
if __name__ == "__main__":
    X = int(input())
    # n = 1
    # while True:
    #     if n**5 - (n-1)**5 > X:
    #         print(n)
    #         break # x=10^9 で n=120
    #     n += 1
    
    n = 1
    while True:
        i = 0
        while True:
            #print("{} {}".format(int(n), int(i)))
            sign = np.sign(n**5 - i**5 - X)
            #print(sign)
            if sign == 0:
                print("{} {}".format(int(n), int(i)))
                sys.exit()
            elif sign < 0:
                i -= 1
            else:
                i += 1
            #print(i)
            if i <= -n or n-1 <= i:
                break
        n += 1

Submission status: Time Limit Exceeded

Solution code:

x = int(input())

for i in range(100):
    for j in range(100):
        if pow(i, 5)+pow(j, 5) == x:
            print(i, -j)
            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


a = 0
for i in make_divisors(x):
    a = i
    b = 0
    while pow(a, 5)-pow(b, 5) > x:
        if pow(a, 5)-pow(b, 5) == x:
            print(a, b)
            exit()
        b += 1
        a += 1

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
x = int(input())
y = x ** 0.2

if (y - int(y)) == 0.0:
    a = int(y)
    b = 0
    print("{} {}".format(a, b))

else:
    a = int(y)
    a5 = a**5
    flag = True

    if (a5 - x) < 0:
        for b in range((-a+1), 0):
            if (a5 - b**5) == x:
                print("{} {}".format(a, int(b)))
                flag = False

    while flag:
        for b in range(1, a):
            if (a5 - b**5) == x:
                print("{} {}".format(a, int(b)))
                flag = False

        a = a + 1

Submission status: Time Limit Exceeded

Solution code:
import math
X = int(input())
answer = 0
a=0
b=0
A= 0
i = 0
ma = 0
while True:
  A = X - i ** 5
  for j in range(0,10*2):
    if A >= 0:
      ma = math.pow(A, 1.0/5.0)
  if type(ma)=='int':
    a = i
    B = j
    break
  i = i + 1
print(a,b)

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
a=int(x**(1/5))+1
l=list(range(a+1))
s=[]
m=0
n=0
w=0
e=1
r=0
for i in l:
  k=i**5
  l[i]=k
for i in l:
  s.append(i*-1)
p=l+s
for i in p:
  if m==1:
    break
  for q in p:
    if x==i-q:
      print(int(i**(1/5)),end=" ")
      m+=1
      if p.index(q)<=a+1:
        print(p.index(q))
      else:
        print((p.index(q)-a-1)*-1)
      break
if m==0:
  while  n==0:
    u=e**5-w**5
    if u>x:
      r+=1
      w=r
      e=r+1
    if x==u:
      print(e,end=" ")
      print(w)
      n+=1
    else:
      e+=1

Submission status: Time Limit Exceeded

Solution code:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def check(a,b,x):
    a=round(a)
    return a**5 - b**5 == x

def fifthroot(n):
    for i in range(int(n**(1/5)+1)) :
        if i**5==n:
            return i
    return -1

def main():
    x = int(input().strip())
    # b>=0 のとき
    for b in range(1,10**9):
        if fifthroot(x + b**5)!=-1:
            eprint("b>=0")
            a=fifthroot(x + b**5)
            print(a,b)
            return
        # #
        # a=(x + b**5)**(1/5)
        # eprint('a ',end=':\n')
        # eprint(a)
        # if check(a,b,x):
        #     eprint("b>=0")
        #     print(int(a),b)
        #     return            

        #
        # if a.is_integer():
        #     eprint("b>=0")
        #     print(a,b)
        #     return
    
    # b<0の場合
    for a in range(1,10**9):
        if x - a**5 < 0:
            break
        # b=(x - a**5) ** (1/5)
        b=fifthroot(x - a**5)
        if b!=-1:
            eprint("b<0")
            print(a,-int(b))
            return

    for a in range(-10**2, 10**2):
        pass

if __name__ == '__main__':
    main()

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 = 0
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
K = 1
while K < X:
    A += 1
    K = A ** 5
S = A - 7
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
print(S,B)

Submission status: Time Limit Exceeded

Solution code:
x = int(input());
n1 = 0;
n2 = 0;
if(x == 1):
    n1 = 0;
    n2 = -1;
    print(n1, n2);
flag = False;

if(x != 1):
    for i in range(x):
        for j in range(x):
            if((i * i * i * i * i) - (-(j * j * j * j * j)) == x ):
                print(i, -j);
                flag = True;
                break;
        if(flag):
            break;

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 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())
import math
def is_prime(n):
    if n == 1:
        return True
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
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
if is_prime(x) == True:
    i = 0
    while True:
        if (i + 1) ** 5 - i ** 5 == x:
            ans = [i + 1, i]
            break
else:
    l = prime_factorize(x)
    l = list(set(l))
    k = 0
    ans = 0
    while True:
        for d in range(len(l)):
            if (k) ** 5 - (k - l[d]) ** 5 == x:
                ans = [k, k - l[d]]
            elif (-k) ** 5 - (-k - l[d]) ** 5 == x:
                ans = [-k, -k - l[d]]
        k += 1
        if ans != 0:
            break
print(" ".join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
def main():
    x = int(input())
    c = x%5
    while x%c!=0:
        c+=5
    a=1
    ans = (x-c**5)//5
    while c*a**3-2*c**2*a**2+2*c**3*a-c**4!=ans//a:
        a+=1
    print(a,a-c)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
x = int(input())
if x > 0:
    for a in range(-1, x):
        for b in range(-1, x):
            check = math.pow(a, 5) - math.pow(b, 5)
            if check == x:
                print(f'{a} {b}')
                break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
a=0
b=0
end=0
for i in range(99999999999):
  if(end):
    break
  for k in range(99999999999):
    if(i*i*i*i*i-k*k*k*k*k==x):
      a=i
      b=k
      end=1
    elif(i*i*i*i*i+k*k*k*k*k==x):
      a=i
      b=-k
      end=1
    elif(-i*i*i*i*i-k*k*k*k*k==x):
      a=-i
      b=k
      end=1
    elif(-i*i*i*i*i+k*k*k*k*k==x):
      a=-i
      b=-k
      end=1

print(str(a)+" "+str(b))

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
Y = [1]
count=0
for i in range(2, X+1):
  if X%i == 0:
    Y.append(i)
for y in Y:
  for A in range(-X, X+1):
    B = A - y
    if A**4+A**3*B+A**2*B**2+A*B**3+B**4==int(X/y):
      print('{0} {1}'.format(A, B))
      break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
b = 0
while 1:
    a = (x + b**5)**(1/5)
    if type(a) == float:
        if a.is_integer() == True:
            if a**5 - b**5 == x:
                a = int(a)
                print(a, b)
                break
            else:
                a = int(a)
                print(-a, b)
                break
    b += 1

Submission status: Time Limit Exceeded

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

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

def mkDivisors(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 = ni()
    xmod10 = x%10
    div = mkDivisors(x)
    random.shuffle(div)
    for i in div:
        for n in [i,-1*i]:
            if n%10 == xmod10:
                for b in range(-n-125, n+125):
                    a = b + n
                    if pow(a,5) - pow(b,5) == x:
                        print(a,b)
                        return
    print("Erorr")
    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
 
for d in range(1, int(x**0.5)+1):
    if x % d == 0:
        for a in range(0,x+1):
            b = a - d
            if a**5 - b**5 == x:
                print(a, b)
                exit()
            elif a**5 - b**5 > x:
                continue

Submission status: Time Limit Exceeded

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

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
print(S,B)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
diff = 1
for i in range(2,X):
    if X % i == 0:
        diff = i
        break

s = (10 **9)//2
while True:
    ss = s//2
    A = ss 
    B = ss - diff
    xx = A ** 5 - B ** 5
    if xx == X:
        break
    elif xx > X:
        s = ss //2
    else:
        s =  (3*ss) //4
print(int(A),int(B))

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(1,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
  r = list(range(0,1000000+1))
  for a in r:
    b = a - i[1]
    if a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4 == i[0]:
      print(a,b)
      flag = 1
      break
  if flag==1:
    break

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
for a in range(0, 10**4):
    for b in range(0, 10**4):
        if X == a**5 - b**5:
            print(a, b)
            exit()
        elif X == a**5 + b**5:
            print(a, -b)
            exit()
        elif X == a**5 - (10**4 - b)**5:
            print(a, 10**4 - b)
            exit()
        elif X == -a**5 - (10**4 - b)**5:
            print(-a, 10**4 - b)
            exit()

Submission status: Time Limit Exceeded

Solution code:
import math
X=int(input())
A=math.ceil(X**(1/4))
for a in reversed(range(0,A)):
  for b in reversed(range(-10**9,a)):
    if (a-b)*(a**4+a**3*b+a**2*b**2+a*b**3+b**4)==X:
      print(str(a)+" "+str(b))
      exit()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A = 0
B = 0
answer = 0
while answer != X:
    answer = A ** 5 - B ** 5
    if answer < X:
        A += 1
    #下げる
    if answer > X:
        B -= 1
        A -= 1
print(A,B)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

x=int(input())
resa = 0
resb = 0

for i in range(x*2):
  for j in range(x*2):
    if pow(i-x,5) - pow(j-x,5) == x:
      resa = i-x
      resb = j-x
      break

print(str(resa) + " " + str(resb))

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
i = 0
while i < 100000000000000:
  A = i
  if (i**5-X) == -1:
    B = -1
    if A**5 - B**5 == X :
      break
  elif isinstance((i**5-X)**(1/5), float):
    B = int((i**5-X)**(1/5))

    if A**5 - B**5 == X :
      break
  A = -i
  if (i**5-X) == -1:
    B = -1
    if A**5 - B**5 == X :
      break
  elif isinstance((i**5-X)**(1/5), float):
    B = int((i**5-X)**(1/5))

    if A**5 - B**5 == X :
      break
  i = i+1


print(A, B)

Submission status: Time Limit Exceeded

Solution code:
import math

X = int(input())

for i in range(X):
  if X % (i + 1) == 0:
    A_B = i + 1
    for k in range((A_B // 2) + 1):
      A = A_B - k
      B = 0 - k
      C = (A ** 4) + (A ** 3) * B + (A ** 2) * (B ** 2) + A * (B ** 3) + (B ** 4)
      if A_B * C == X:
        print("{} {}".format(A,B))
        break
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
from math import ceil, sqrt
x = int(input())
# x = a**5 - b**5
# a**5 - b**5 = (a − b)(a**4 + a**3b + a**2b**2 + ab**3 + b**4)
def get_factors(n):
  set_factors = {n}
  q = n
  for i in range(1, ceil(sqrt(n))):
    if q%i == 0:
      set_factors.add(i)
      q = q//i
    if q<=1: return set_factors
  return set_factors
all_factors = get_factors(x)
def test_factor(factor):
  upper = x
  lower = 0
  while upper!=lower:
    a = (upper+lower)//2
    if a**5-(a-factor)**5 < x:
      lower = a
    elif a**5-(a-factor)**5 == x:
      return (a, a-factor)
    else:
      upper = a
  return None
for factor in all_factors:
  result = test_factor(factor)
  if result!=None:
    print(result[0], result[1])
    break

Submission status: Time Limit Exceeded

Solution code:
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

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

def read_s_list_loop(n):
    return [input() for _ in range(n)]

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

X = read_int()
prime_value  = prime_factorize(X)
if X == 1:
    diff = 1
else:
    diff = prime_value[0]

a = diff
b = 0
## + & +
while True:
    tmp_x =  (a**5 - b**5)
    if tmp_x == X:
        print(a,b)
        exit(0)
    elif tmp_x > X:
        break
    a += 1
    b += 1

a = diff
b = 0
## + & - and -
while True:
    tmp_x =  (a**5 - b**5)
    if tmp_x == X:
        print(a,b)
        exit(0)
    a -= 1
    b -= 1

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
for i in range(-10,10000,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:
X=int(input())
for A in range(X):
  for B in range(-X,X):
    if A*A*A*A*A-B*B*B*B*B==X:
      print(A,B)
      exit()

Submission status: Time Limit Exceeded

Solution code:
import os

def main():
	x = int(input())
	b = 0 
	while(x + b**5 != 1):
		b -= 1
	print(1,b)
			


if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
import math
X = int(input())
A=[]
B=[]
number = []
flag = 0
for i in range(math.ceil(X/2) * -1, math.ceil(X/2) + 1):
    number.append(i)
    A.append(i ** 5)
    B.append(i ** 5)

for i in range(len(A)):
    for j in range(len(B)):
        if(A[i] - B[j] == X and flag == 0):
            print(number[i],number[j])
            flag += 1

Submission status: Time Limit Exceeded

Solution code:
s = int(input())
for i in range(-s, s):
    for j in range(-1, s):
        if i**5-j**5 == s:
            if i == abs(j)+1 or abs(j) == i+1:
                print(i, j)
                break

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)

    divisors.sort()
    return divisors

x = int(input())
a = 0
b = 0
flag = False
for i in range(10**7):
    tmp = ((x + i**5)**(1/5)).real
    if tmp.is_integer():
        b = i
        a = x + b**5
        flag = True
        break
if flag == False:
    for i in range(-10**7,0):
        tmp = ((x + i**5)**(1/5)).real
        if tmp.is_integer():
            b = i
            a = x + b**5
            flag = True
            break
print(int(a),int(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):
        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:
x = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
diff = 1
for i in range(2,X):
    if X % i == 0:
        diff = i
        break

s = (10 **9)//2
while True:
    ss = s/2
    A = ss 
    B = ss - diff
    xx = A ** 5 - B ** 5
    if xx == X:
        break
    elif xx > X:
        s = ss //2
    else:
        s =  (3*ss) //4
print(int(A),int(B))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

#約数列挙
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

#main
X = int(input())
F = make_divisors(X)
#intのみのlistは、直接.join()できない
S = [int(x) for x in F]

if X == 1:
    print('0 -1')
else:
    for i in range(1, len(S)):
        tmp = S[i]
        for A in range(S[i-1], S[i+1]):
            B = A - tmp
            if A**5 - B**5 == X:
                print(str(A) + ' ' + str(B))
                break
        else:
            continue
        break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
 
for d in range(1, int(x**0.5)+1):
    if x % d == 0:
        for a in range(0,x+1):
            b = a - d
            if a**5 - b**5 == x:
                print(a, b)
                exit()

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
a=0
b=0
end=0
for i in range(99999999999):
  if(end):
    break
  for k in range(99):
    if(i*i*i*i*i-k*k*k*k*k==x):
      a=i
      b=k
      end=1
    elif(i*i*i*i*i+k*k*k*k*k==x):
      a=i
      b=-k
      end=1
    elif(-i*i*i*i*i-k*k*k*k*k==x):
      a=-i
      b=k
      end=1
    elif(-i*i*i*i*i+k*k*k*k*k==x):
      a=-i
      b=-k
      end=1

print(str(a)+" "+str(b))

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


p = factorization(x)
# print(p)
Bas = 0
Aas = 0
for i in range(1):
    _p = p[i][0]
    # print(_p)
    B = 0
    while True:

        xnew_p = (B + _p)**5 - B ** 5
        xnew_n = (-1*B + _p)**5 - (-1*B) ** 5
        # print(B, xnew_p, xnew_n)
        if xnew_n == x:
            # print('?')
            Bas = -1*B
            Aas = -B + _p
            break

        if xnew_p == x:
            # print('!')
            Bas = B
            Aas = + _p
            break
        B += 1

print(f'{Aas} {Bas}')

Submission status: Time Limit Exceeded

Solution code:


def sovle_odd(X):
    max = 200000
    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 = 500000
    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 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()
bfp = 0
bcp = 0
bfm = 0
bcm = 0
while True:
    for a in range(y - cnt, y + cnt + 1):
        a5 = a**5
        t = (a5 - x)**(1/5)
        if isinstance(t, complex):
            bfp = floor(t.real)
            bcp = ceil(t.real)
            bfm = bfp * -1
            bcm = bcp * -1
        else:
            bf = floor(t)
            bc = ceil(t)
            bfm = bfp * -1
            bcm = bcp * -1
        if a5 - bfp**5 == x:
            print(a, bfp)
            sys.exit()
        elif a5 - bcp**5 == x:
            print(a, bcp)
            sys.exit()
        elif a5 - bfm**5 == x:
            print(a, bfm)
            sys.exit()
        elif a5 - bcm**5 == x:
            print(a, bcm)
            sys.exit()
    cnt += 1