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
a=int(input())
i=0
j=1
t=True
while i**5<=a:
  if int((a-i**5)**0.2)==(a-i**5)**0.2:
    print(i,int((-1)*(a-i**5)**0.2))
    sys.exit()
  i+=1
while t:
  if i**5-j**5>a:
    j+=1
  elif i**5-j**5<a:
    i+=1
  else:
    print(i,j)
    sys.exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1,int(n**(1/2))+1):
    if n%i!=0:
        continue
    x,y = i,n//i
    a=0
    b=-x
    while 1:
        tmp = a**5-b**5
        if tmp==n:
            print(a,b)
            exit()
        if b>0:
            break
        a+=1
        b+=1
    a=0
    b=-y
    while 1:
        tmp = a**5-b**5
        if tmp==n:
            print(a,b)
            exit()
        if b>0:
            break
        a+=1
        b+=1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
import math
read = sys.stdin.readline

X = int(input())


for a in range(1,10000):
    for b in range(0,10000):
        a4 = a ** 4
        b4 = b ** 4
        a3 = a ** 3
        b3 = b ** 3
        a2 = a ** 2
        b2 = b ** 2
        if ( (a-b)*( a4 + (a3*b) + (a2 * b2) + (b3 * a) + b4) ) == X:
            print(a,b)
            sys.exit()

        b = -1 * b
        b3 = -1 * b3
        if ( (a-b)*( a4 + (a3*b) + (a2 * b2) + (b3 * a) + b4) ) == X:
            print(a,b)
            flag = 1
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
a=0
while ans==0:
  b=0
  c=0
  while pow(a,5)-pow(b,5)<=n and pow(a,5)-pow(b,5)>0:
    if pow(a,5)-pow(b,5)==n:
      print(str(a)+" "+str(b))
      ans=1
    b=b+1
  if ans==1:
    break
  while pow(a,5)-pow(c,5)<=n and pow(a,5)-pow(c,5)>0:
    if pow(a,5)-pow(c,5)==n:
      print(str(a)+" "+str(c))
      ans=1
    c=c-1
  a=a+1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#input
X = int(input())

#output
left = 1
right = 10**2
while left + 1 < right:
    mid = (left + right)//2
    if mid **5  > X:
        right = mid
    else:
        left = mid

A = right
C = A**5 -X

if C >= 0:
    B = pow(C, 1/5)
else:
    B = -pow(-C, 1/5)

while not B.is_integer():
    A -= 1
    C = A**5 - X
    if C >= 0:
        B = pow(C, 1/5)
    else:
        B = -pow(-C, 1/5)
print(A, int(B))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

import math


def fact(x):
    for cand in range(2, math.ceil(math.sqrt(x)) + 1):
        q, r = divmod(x, cand)
        if r == 0:
            return min(q, cand), max(q, cand)
    return 1, x


# def check(a, b):
#     a2 = a * a
#     a3 = a2 * a
#     a4 = a3 * a
#     b2 = b * b
#     b3 = b2 * b
#     b4 = b3 * b
#     return a4 + a3*b + a2*b2 + a*b3 + b4

def pow5(x):
    return x ** 5


def func(a, b):
    return pow5(a) - pow5(b)


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

    if x == 1:
        print("0 -1")
        return

    q1, q2 = fact(x)

    # パターン1, a, b > 0
    a = q1
    b = 0
    f = func(a, b)
    while f < x:
        a += 1
        b += 1
        f = func(a, b)
    if f == x:
        print("{} {}".format(a, b))
        return

    # パターン2 a > 0, b < 0
    a = q1 - 1
    b = -1
    f = func(a, b)
    while a > 0 and f != x:
        a -= 1
        b -= 1
        f = func(a, b)
    if f == x:
        print("{} {}".format(a, b))
        return

    # パターン3 a, b < 0
    a = 0
    b = -q1
    f = func(a, b)
    while f != x:
        a -= 1
        b -= 1
        f = func(a, b)
    if f == x:
        print("{} {}".format(a, b))
        return

        
submit()

Submission status: Time Limit Exceeded

Solution code:
import math


def search(a, x):
    b_5 = a ** 5 - x
    b = math.pow(abs(b_5), 1 / 5)
    if b_5 < 0:
        b *= -1
    return b


def main():
    x = int(input().strip())
    a = 0
    while True:
        a1 = a
        a2 = -1 * a

        b1 = search(a1, x)
        b2 = search(a2, x)

        if b1 == int(b1):
            a = a1
            b = b1
        if b2 == int(b2):
            a = a2
            b = b2
        a += 1
    print('{} {}'.format(int(a), int(b)))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A = -30
B = -30
while True:
    A += 1
    B += 1
    if (A ** 5) - (B ** 5) == X:
        print(A, B)
        break

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

for i in range(len(make_divisors(X))):
    A = make_divisors(X)[i]
    for j in range(A*(-1),int(X**(1/5))):
        if (A+j)**5-j**5==X:
            a = j + A
            b = j
            break
        else:
            continue
        break
    else:
        continue
    break
print(a,b)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

i = 1
a = 1
b = 0
while a**5 - b**5 <= x:
    if a**5 - b**5 == x:
        print(a, b)
        exit
    a += 1
    b -= 1

while True:
    i += 1
    if x % i:
        continue

    b = 1
    a = i - b
    while b < a and a**5 - b**5 <= x:
        if a**5 - b**5 == x:
            print(a, b)
            exit
        a += 1
        b -= 1

    a = i
    b = 0
    while a**5 - b**5 <= x:
        if a**5 - b**5 == x:
            print(a, b)
            exit
        a += 1
        b -= 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 - 2
w = 0
while w != 1:
    P = S ** 5
    Q = P - X
    if Q < 0:
        B = 0
        while (Q != B**5):
            B -= 1
            if Q>(B**5):
                break
        if (Q == B**5):
            w += 1
        else:
            S += 1
        
    elif Q > 0:
        B = 0
        while (Q != B**5):
            B += 1
            if Q<(B**5):
                break
        if (Q == B**5):
            w += 1
        else:
            S += 1
print(S,B)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys

X = int(input())

for i in range(-10,X+1):
    if i == 0:
        continue
    tmp = X / i
    if tmp.is_integer():
        # for j in range(-i,int(tmp)):
        p = []
        if int(tmp) < i:
            p.append(int(tmp))
            p.append(i)
        else:
            p.append(i)
            p.append(int(tmp))

        for k in p:
            for j in range(-i,k):
                a = j
                b = i - a
                # print("tmp = {}".format(tmp))
                # print("a = {}".format(a))
                # print("b = {}".format(b))
                if a**5 - b**5 == X:
                    print("{} {}".format(a,b))
                    sys.exit()
                if b**5 - a**5 == X:
                    print("{} {}".format(b,a))
                    sys.exit()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A = 0
B = 0

while True:
  ans = A**5-B**5
  if ans == X:
    break
  elif ans < X:
    B -= 1
  elif ans > X:
    B += 1
    A += 1
print("{} {}".format(A,B))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
def check(i):
    a = 1
    while True:
        b = a - i
        temp = pow(a, 5) - pow(b, 5)
        #if i == 17:print(temp, a, b)
        if temp == x:
            return (a, b)
        if b > 0 and temp > x:
            return -1
        a += 1

num = int(pow(x, 0.5)//1)
for i in range(1, num + 1):

    if x % i == 0:
        temp = check(i)
        temp1 = check(x//i)
        if temp == -1 and temp1 == -1:continue
        else:
            if temp != -1:print(*temp)
            else:print(*temp1)
            exit()

Submission status: Time Limit Exceeded

Solution code:
import math

X = int(input())


def calculate(x):

    loop = True
    b = 0
    while loop:
        tmp1 = x + b ** 5
        a1 = math.pow(tmp1, 0.2)

        if float.is_integer(a1):
            print(int(a1), int(b))
            break

        tmp2 = x + (-1 * b) ** 5
        if tmp2 < 0:
            b = b + 1
            continue
        else:
            a2 = math.pow(tmp2, 0.2)
            if float.is_integer(a2):
                print(int(a2), int(-1*b))
                break
            b = b + 1

calculate(X)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

x = int(input())

end = math.floor(x**0.2)

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    x = int(input())
    c = x%5
    while x%c!=0:
        c+=5
    ans = (x-c**5)/c/5
    def f(x):
        return c**3*x + 2*c**2*x**2+2*c*x**3+x**4-ans
    if f(0)>0:
        b=-1
        while f(b)!=0:
            b-=1
    elif f(0)==0:
        b = 0
    else:
        b=1
        while f(b)!=0:
            b+=1
    print(int(b+c),int(b))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math

X = int(input())

ans = None

while ans is None:
  for i in range(math.ceil(abs(X)**0.5)+1, 0, -1):
    for j in range(math.ceil(abs(X)**0.5)+1, 0, -1):
      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)
      elif (i*-1) ** 5 - (j*-1) ** 5 == X:
        ans = (-i, -j)
print(ans[0],ans[1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1,int(n**(1/2))+1):
    if n%i!=0:
        continue
    x,y = i,n//i
    a=0
    b=-x
    while 1:
        tmp = a**5-b**5
        if tmp>n:
            if b<0:
                a+=1
                b+=1
                continue
            break
        if tmp==n:
            print(a,b)
            exit()
        a+=1
        b+=1
    a=0
    b=-y
    while 1:
        tmp = a**5-b**5
        if tmp>n:
            if b<0:
                a+=1
                b+=1
                continue
            break
        if tmp==n:
            print(a,b)
            exit()
        a+=1
        b+=1

Submission status: Time Limit Exceeded

Solution code:
import math

X = int(input())

for B in range(X):
    A_f = math.floor(math.pow(X+B**5, 0.2))
    A_c = math.ceil(math.pow(X+B**5, 0.2))

    # print(B)

    if A_f**5 - B**5 == X:
        print(A_f,B)
        break
    if A_c**5 - B**5 == X:
        print(A_c,B)
        break
    if A_f**5 + B**5 == X:
        print(A_f,-B)
        break
    if A_c**5 + B**5 == X:
        print(A_c,-B)
        break

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
for B in range(1,10**9) :
  A=X**0.2+B
  print(f'(A,B)=({A},{B})')

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
divisors = []
for i in range(1, int(x**0.5)+1):
    if x % i == 0:
        divisors.append(i)
        if i != x // i:
            divisors.append(x//i)
for i in divisors:
    for a in range(x//2+1):
        b=a-i
        if a**4+(a**3)*b+(a**2)*(b**2)+a*(b**3)+b**4==x/i:
            print(str(a)+" "+str(b))
            exit()

Submission status: Time Limit Exceeded

Solution code:
import sys

X = int(input())
A = []
for i in range(1, int(X**0.5)+1):
    if X%i == 0:
        A.append([i, X//i])

for i in A:
    for a in range(1, X+1):
        b = a - i[0]
        if a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4 == i[1]:
            print(a, b)
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
a=0
b=0
s=0
while(1):
    while(1):
        A=a**5
        B=b**5
        if(A-B==x):
            print(a,b)
            s=1
            break
        elif (-A-B==x):
            print(-a,b)
            s=1
            break
        elif (A+B==x):
            print(a,-b)
            s=1
            break
        if(a==b):
            break
        b+=1
    if(s==1):
        break
    a+=1

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

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

def gen_candidates(limit, divisor):
    for a in range(limit):
        yield (a, a - divisor)


for divisor in gen_divisor(x):
    for a, b in gen_candidates(x + 1, divisor):
        if a**5 - b**5 == x:
            print(a, b)
            break
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

A = 0
while(True):
    if(pow(A, 5) >= X):
        break
    else:
        A += 1

Aminus1 = A-1
Apow5 = pow(A,5)
Aminus1pow5 = pow(A-1, 5)

B = 0
while(True):
    Bpow5 = pow(B, 5)
    if(Apow5-Bpow5 == X):
        print(A, B)
        break
    elif(Aminus1pow5 + Bpow5 == X):
        print(A-1, -B)
        break
    else:
        B +=1

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:
        if X+B**5<0:
            B = B+1
            continue
        A_principle = (X+B**5)**(1/5)
        if (A_principle-(A_principle//1))==0:
            print(str(int(A_principle))+" "+str(B))
            break
        B = B+1

if __name__ == '__main__':
    main()

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())
b = 0
while True:
  if (x+b**5)**(1/5) == int((x+b**5)**(1/5)):
    break
  b += 1
print(int((x+b**5)**(1/5)), b)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
a=0
while True:
    b=a**5-x
    if b<0:
        b=-((-b)**(1/5))
    else:
        b=b**(1/5)
    try:
        c=int(b)
    except:
        a+=1
    else:
        if b==c and a**5-c**5==x:
            print(str(a)+" "+str(c))
            break
        else:
            a+=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
div = make_divisors(x)
for d in div:
    for a in range(0,d+1):
        b = a - d
        if a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4 == x/d:
            print(a, b)
            break

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

def main():
    X = int(input())
    ROOT = 1/5
    for a in range(-10000000, 10000000):
        a5 = a ** 5
        b = a5 - X
        b_root = abs(b)**ROOT
        if not is_integer_num(b_root):
            continue
        if b < 0:
            if a5 + b_root ** 5 == X:
                print(a, -int(b_root))
                exit()
        else:
            if a5 - b_root ** 5 == X:
                print(a, int(b_root))
                exit()

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math

X = int(input())

B = 1
while True:
    B_5 = B**5

    diff = X - B_5
    A = diff**(1 / 5)
    if type(A) != complex and math.floor(A) == A:
        B = -B
        A = int(A)
        break

    diff = X + B_5
    A = diff**(1 / 5)
    if type(A) != complex and math.floor(A) == A:
        A = int(A)
        break

    B += 1

print(A, B)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools


x = int(input())
for a in itertools.count():
    for b in itertools.count(a):
        a5b5 = a**5 + b**5
        if a5b5 == x:
            print(a, -b)
            sys.exit(0)
        if x < a5b5:
            break

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:
            print(i, j) 
            break

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]

for i in range(len(S)):
    tmp = S[i]
    for A in range(tmp+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:
import math

X = int(input())

ans = None

while ans is None:
  for i in range(math.ceil(abs(X)**0.5)+1):
    for j in range(math.ceil(abs(X)**0.5)+1):
      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)
      elif (i*-1) ** 5 - (j*-1) ** 5 == X:
        ans = (-i, -j)
print(ans[0],ans[1])

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
div = []
for i in range(1, int(X**0.5)+1):
    if X % i == 0:
        div.append(i)
        if i != X // i:
            div.append(X//i)
div.remove(1)
if X == 1:
    div.append(1)
    div.append(1)
a = 0
while True:
    b = a - div[1]
    if  a**5 - b**5 == X:
        print(str(a) + ' ' + str(b))
        break
    else:
        a += 1

Submission status: Time Limit Exceeded

Solution code:
import sys
from io import StringIO
import unittest
import math

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

    a = math.floor(x ** 0.2)

    b5 = a ** 5 - x
    b = 0

    if b5 != 0:
        while 1:
            b -= 1
            if b5 == (b ** 5):
                break

    print(a, b, sep=' ')


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """33"""
        output = """2 -1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1"""
        output = """0 -1"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Time Limit Exceeded

Solution code:
# ａ⁵－ｂ⁵＝(ａ－ｂ)(ａ⁴＋ａ³ｂ＋ａ²ｂ²＋ａｂ³＋ｂ⁴)
import sys
# X = int(input())
# a = 1
# for i in range(1, 10**9):
#     a = i**5
#     if a-X > 0:
#         b = 1
#         while True:
#             if a-X == b**5:
#                 print(i, b)
#                 sys.exit()
#             elif a-X > b:
#                 b += 1
#             else:
#                 break
#     elif a-X < 0:
#         b = -1
#         while True:
#             if a-X == b**5:
#                 print(i, b)
#                 sys.exit()
#             elif a-X < b:
#                 b -= 1
#             else:
#                 break
#     else:
#         print(i, 0)
#         break

from itertools import combinations
X = int(input())
num = X
fact = []
i = 2
# 素因数分解
while num > 1:
    if num%i == 0:
        num //= i
        fact.append(i)
    else:
        i += 1

for i in range(len(fact)+1):
    for item in combinations(fact, i):
        a = 0
        b = -1
        for num in item:
            b *= num
        while a**5 - b**5 >= X:
            if a**5 - b**5 == X:
                print(a, b)
                sys.exit()
            else:
                a += 1
                b += 1

Submission status: Time Limit Exceeded

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


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


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


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


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


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

    divisors.sort()
    return divisors


X = readint()
l = make_divisors(X)

ans_A = 0
ans_B = 0
for n in l:
    # n = A - B
    A = 0
    B = A - n
    while A != n:
        if A ** 5 - B ** 5 == X:
            ans_A = A
            ans_B = B
            break
        else:
            A += 1
            B += 1

    if ans_A:
        break


print(ans_A, ans_B)

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:
    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())
a=0
b=0
def f(n):
    n1 = n**(1/5)
    if n1==int(n1):
        return True

l=set()
l.add(0)
i=1
while i<2*x:
    i1=i**5
    l.add(i1)
    if i%2==1:
        l.add(-i1)
    i+=1

for i in l:
    b=i
    a=x+b
    if a in l:
        if a!=0 and b!=0:
            a1=(a/abs(a))*(abs(a)**(1/5))
            b1=(b/abs(b))*(abs(b)**(1/5))
            print(int(a1),int(b1))
        elif b==0:
            a1=(a/abs(a))*(abs(a)**(1/5))
            print(int(a1),0)
        else:
            b1=(b/abs(b))*(abs(b)**(1/5))
            print(0,int(b1))
        break

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
x = int(stdin.readline().rstrip())

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


for i in range(1,x):
    if x%i==0:
        for a in range(i):
            b = a-i
            if int(a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4) == int(x/i):
                print(a,b)
                exit()
    else:
        pass

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools


x = int(input())
for a in itertools.count():
    for b in itertools.count():
        a5b5 = a**5 + b**5
        if a5b5 == x:
            print(a, -b)
            sys.exit(0)
        if x < a5b5:
            break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
c = [int(i) for i in range(-x, x+1) if i!=0 and x%i == 0]
for c in c:
    for i in range(10):
        a, b = c-i, -i
        if a**5 - b**5 == x:
            print(a, b)
            exit()
        a, b = c+i, i
        if a**5 - b**5 == x:
            print(a, b)
            exit()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
x = int(input())
for a in range(10**10):
    fp = True
    fm = True
    f = False
    for b in range(10**10):
        if fp:
            if a**5-b**5 == x:
                print(a,b)
                f = True
                break
            elif a**5-b**5 > x:
                fp = False
        if fm:
            if a**5+b**5 == x:
                print(a,-b)
                f = True
                break
            elif a**5+b**5 > x:
                fp = False
        if not (fp and fm):
            break
    if f:
        break

Submission status: Time Limit Exceeded

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

import math

def main():
     x = int(input())
     # x は 正の整数
     # ans = a^5 - b^5 = x となる a, b

     b = 0
     while(True):
          b_x = pow(b, 5)
          a_x = x + b_x
          a = pow(a_x, 1 / 5)

          # print('a:{}, b:{}'.format(a, b))

          if type(a) == float:
               if a.is_integer():
                    print(int(a), b)
                    break

          if b <= 0:
               b -= 1
               b = b * (-1)
          else:
               b = b * (-1)

if __name__ == "__main__":
    main()

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 (ar**5)%5==x%5:pre.append(ar)
    if  ((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**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:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

x = int(readline())
for i in range(100000):
    for j in range(-2000, i):
        v = i ** 5 - j ** 5
        if x == v:
            print(i, j)
            exit()
        if len(str(v)) >= 10 and j > 0:
            break

Submission status: Time Limit Exceeded

Solution code:
# D - I hate Factorization

X = int(input())
fact = []
for i in range(10**5):
    fact.append(pow(i,5))

for i in range(10**5):
    for j in range(10**5):
        if fact[i]-fact[j]==X:
            print(i, j)
            break
        elif fact[i]+fact[j]==X:
            print(i, -j)
            break
    else:
        continue
    break

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 (ar**5)%5==x%5:pre.append(ar)
    if  ((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())
Acount = 0
Bcount = 0
di= {}
def func(i):
    return i**5
for i in range(3000):
    di[str(func(i))] = str(i)
preA = int(X **(1/5))
while True:
    funcA = preA**5
    if funcA-X>=0 and str(funcA-X) in di.keys():
        print(str(preA)+" "+di[str(funcA-X)])
        break
    elif X-funcA>= 0 and str(X-funcA) in di.keys():
        print(str(preA)+" -"+di[str(X-funcA)])
        break
    preA += 1

Submission status: Time Limit Exceeded

Solution code:
import sys
def main():
    N=int(input())

    for i in range(-64,64):
        for j in range(-64,64):
            if i**5-j**5==N:
                print(i,j)
                sys.exit(0)

    a=65
    b=64
    for i in range(10000000):
        ass=a**5-b**5
        if ass==N:
            print(a,b)
            sys.exit(0)
        #elif ass>N:
        #    b+=1
        else:
            b+=1
            a+=1

if __name__ =='__main__': 
    main()

Submission status: Time Limit Exceeded

Solution code:
#input
X = int(input())

#output

import math
initial_num = 1

left = 1
right = 10**2
while left + 1 < right:
    mid = (left + right)//2
    if mid **5  > X:
        right = mid
    else:
        left = mid

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()
A = left
C = A**5 -X

if C >= 0:
    B = pow(C, 1/5)
else:
    B = -pow(-C, 1/5)

while not is_integer(B):
    A -= 1
    C = A**5 - X
    if C >= 0:
        B = pow(C, 1/5)
    else:
        B = -pow(-C, 1/5)

print(A, int(B))

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
Acount = 0
Bcount = 0
di= {}
def func(i):
    return i**5
for i in range(10000):
    di[str(func(i))] = str(i)
preA = int(X **(1/5))
while True:
    funcA = preA**5
    if funcA-X>=0 and str(funcA-X) in di.keys():
        print(str(preA)+" "+di[str(funcA-X)])
        break
    elif X-funcA>= 0 and str(X-funcA) in di.keys():
        print(str(preA)+" -"+di[str(X-funcA)])
        break
    preA += 1