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:
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


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())
    x_divisors = make_divisors(x)
    for div in x_divisors:
        for b in range(x):
            flag = 0
            b *= - 1
            a = b + div
            item = a ** 4 + (a ** 2) * (b ** 2) + b ** 4 + \
                a * (b ** 3) + b * (a ** 3)
            if item == (x // div):
                print(a, b)
                flag = 1
                break
        if flag == 1:
            break


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
X=int(input())
Cout=3
B=0
Fend=0
while Fend!=1:
    
    A=pow(X+B**5,1/5)
    if type(A)=="complex":
        A=A.imag
        A=int(A)
    if A==math.floor(A):
        print(str(int(A))+" "+str(int(B)))
        Fend=1
    Cout=Cout+1
    if Cout%2==0:
        B=-B
    else:
        B=B+1

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np
# import queue
# import heapq


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


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


def main():
    print(*solve())


def solve():
    X = int(input())
    facts = factorization(X)

    facts.sort(key=lambda x: x[0])
    f0 = facts[0][0]

    f1 = X // f0

    for a in range(10**7):
        b = a - f0
        if r(a, b) == f1:
            return a, b


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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


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

    # a は足す一方なので，
    b_min = -int(x ** (1 / 5))
    for n in insu:
        b = b_min
        while 1:
            a = b
            while 1:
                a += n
                if a < 0:
                    continue
                cand = a ** 5 - b ** 5
                if cand == x:
                    return f'{a} {b}'
                elif cand > x:
                    break
            b += 1


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

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:
        if (X-pow(d,5))%10!=0:
            continue
        for i in range(-d,X):
            Y=pow(i+d,5)-pow(i,5)
            if Y==X:
                print(i+d,i)
                sys.exit()
            elif Y>X and i>0:
                break

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
i = 0
j = -1
while True:
  if i**5 - j**5 == x:
    break
  i += 1
  j -= 1
print(i,j)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
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 lef(a, b):
    return a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b

def solve(X: int):
    divs = make_divisors(X)
    for d in divs:
        base = 0
        upper = X // d
        while(lef(base+d,base) < upper):
            base+=1
        if lef(base+d,base) == upper:
            print(base+d,base)
            return

        base = 0
        while(base > -d-1):
            base -= 1
            if lef(base+d, base) == upper:
                print(base+d, base)
                return

        # base = -d
        # while(lef(base+d,base) < upper) and (base < -d//2+1):
        #     base += 1
        # if lef(base+d, base) == upper:
        #     print(base+d, base)
        #     return

        base = -d
        while(lef(base+d,base) < upper):
            base -= 1
        if lef(base+d, base) == upper:
            print(base+d, base)
            return
    raise
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
X = int(input())
for i in range(1,int(X**(0.5)+1)):
    if X % i ==0:
        a=0
        b=-i
        while a**5<X**5:
            a+=1
            b+=1
            if a**5-b**5==X:
                print(a,b)
                sys.exit()

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
k=len(str(x))//2
for a in range(-10**k, 10**k, 1):
    for b in range(-10**k, 10**k, 1):
        if ((a**5)-(b**5))==x:
            print(a,b)
            exit()

Submission status: Time Limit Exceeded

Solution code:
# D

x = int(input())

a = int(x**(1/5))
b = int(abs(x-a**5)**(1/5))
i = 1
while True:

    if a**5 - b**5 != x and a**5 - (-b)**5 != x:
        a = int(x**(1/5))+i
        b = int(abs(x-a**5)**(1/5))
        if a**5 - b**5 == x:
            print(a,b)
            break
        elif a**5 - (-b)**5 == x:
            print(a,-b)
            break
        else:
            i += 1
        
    elif a**5 - b**5 == x:
        print(a,b)

    else:
        print(a,-b)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

my_dict = dict()

for i in range(10 ** 6):
    my_dict[i**5] = i

for i in range(-10 ** 6, 10 ** 6):
    target = x + (i ** 5)
    if (- target) in my_dict:
        print(-my_dict[target], i)
        exit()
    elif target in my_dict:
        print(my_dict[target], i)
        exit()

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
import math
import random
n=0
A=0
B=0
while n==0 :
  A=random.randint(-10000,10000)
  B=random.randint(-10000,10000)
  
  if A**5-B**5==X :
    print(A,B)
    n=1
  else :
    pass

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
x = int(input())
#n, k = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
#a = 0
#b = 0
for b in range(0, x+1):
    for a in range(0, x+1):
        if pow(a, 5)-pow(b, 5) == x:
            print(a, end=" ")
            print(b)
            exit()
        elif pow(a, 5)-pow(b*-1, 5) == x:
            print(a, end=" ")
            print(b*-1)
            exit()
        elif pow(a, 5)-pow(b*-1, 5) > x or pow(a, 5)-pow(b*-1, 5) < 0:
            break

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

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

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

for a in range(1, 121):
  for b in range(-100000, 120):
    if b**5 == a**5-X:
      print(a, b)
      break

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)
y = ceil(t)
cnt = 0
if y == floor(t):
    print(y, 0)
    sys.exit()

while True:
    for a in range(y - cnt, y + cnt + 1):
        b = floor(a**5 - x)
        if a**5 - b**5 == x:
            print(a, b)
            sys.exit()
    cnt += 1

Submission status: Time Limit Exceeded

Solution code:
X = int(input())


def get_result(X):
    a = 0
    while True:
        a5 = a ** 5
        c = a5 - X
        if c < 0:
            c = -c
            b = 0
            while True:
                b5 = b ** 5
                if b5 == c:
                    return a, -b
                if b5 > c:
                    break
                b += 1
        a += 1


a, b = get_result(X)
print(a, b)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

for i in range(X):
  if X % (i + 1) == 0:
    A_B = i + 1
    for A in range(i+1):
      B = A - A_B
      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

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

for i in range(-X,X):
    for j in range(-X,X):
        if(i**5-j**5==X):
            print('{} {}'.format(i,j))
            exit()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

for a in range(X):
    flag = True
    for b in range(X):
        if b ** 5 > X:
            flag = False
            break
        if a ** 5 - b ** 5 == X:
            A, B = a, b
            break
        elif b ** 5 - a ** 5 == X:
            A, B = -a, -b
            break
        elif a ** 5 + b ** 5 == X:
            A, B = a, -b
            break
    if flag:
        break

if X == 1:
    print(1, 0)
else:
    print(A, B)

Submission status: Time Limit Exceeded

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

sort()
sorted(reverse=true)

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

Decimal()
'''

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


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


t = int(stdin.readline().rstrip())
data = show_divisors(t)

x = data[0]
if len(data) > 2:
    x = data[int(len(data)/2-1)]
b = 0
while True:
    paraT = ((b + x) ** 4 + b * (b + x) ** 3 + (b ** 2)
             * (b + x) ** 2 + (b ** 3) * (b + x) + b ** 4)
    paraF = ((-b + x) ** 4 + (-b) * (-b + x) ** 3 + ((-b) ** 2)
             * (-b + x) ** 2 + ((-b) ** 3) * (-b + x) + b ** 4)
    if paraT * x == t:
        print(str(b + x) + ' ' + str(b))
        break
    if paraF * x == t:
        print(str(-b + x) + ' ' + str(-b))
        break
    b += 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)

    # divisors.sort()
    return divisors
X = int(input())
fs = make_divisors(X)
for f in fs:
    for B in range(f+1):
        A = B + f
        if(A**5-B**5 == X):
            print(A, B)
            exit()
        elif(A**5+B**5 == X):
            print(A, -B)
            exit()
        A = -B + f
        if(A**5-B**5 == X):
            print(A, B)
            exit()
        elif(A**5+B**5 == X):
            print(A, -B)
            exit()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

# 素因数分解
def prime_factorization(n):
    prime = {}
    tmp = n
    for i in range(2, int(n**0.5)+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if i in prime:
                prime[i] += cnt
            else:
                prime[i] = cnt
    if tmp != 1:
        if tmp in prime:
            prime[tmp] += 1
        else:
            prime[tmp] = 1
    return prime

if x == 1:
    print(0, -1)
else:
    p = prime_factorization(x)
    m = min(p.keys())
    a = 0
    while True:
        b = a - m
        if a ** 5 - b ** 5 == x:
            print(a, b)
            break
        a += 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)%5==x%5:pre.append(ar)
    if  pow(s,5,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())
for i in range(0, X//2+2):
    for j in range(-X//2-2, X//2+2):
        if i**5 - j**5 == X:
            a = i
            b = j
            break

print(a, b)

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
a = int( x**(1/5) )
b = int( x**(1/5) )
p = a**5-x
q = b**5-x
while abs(p**(1/5)).is_integer()!=True and abs(q**(1/5)).is_integer()!=True:
        a-=1
        b+=1
else:
    if abs(p**(1/5)).is_integer()==True:
        if p>=0:
            print(a,int(p**(1/5)))
        else:
            print(a,int(abs(p**(1/5)))*(-1))
    else:
        if q>=0:
            print(b,int(q**(1/5)))
        else:
            print(b,int(abs(q**(1/5)))*(-1))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 21:48:14 2020

@author: Kei
"""

X = int(input())

i = 0
j = 0


while(1):
    A_5 = pow(i,5) + X
    if pow(A_5,0.2).is_integer() == True:
        A = int(pow(A_5,0.2))
        B = i
        break


    if abs(pow(j,5))> X:
        continue
    else:
        A_5 = pow(j,5) + X
        jud = pow(A_5,0.2)
        if jud.is_integer() == True:
            A = int(jud)
            B = j
            break
    
    i += 1
    j -= 1


print(A,B)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

CNT = 2000

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

Submission status: Time Limit Exceeded

Solution code:
import math
X = int(input())

for a in range(1, 3000):
    a4 = a**4
    a3 = a**3
    a2 = a**2
    for b in range(-1, 3000):
        an = (a-b)*(a4 + (a3)*b + (a2)*(b**2) + a*(b**3) + b**4)
        if an < 0:
            break

        if an == X:
            print(a, b)
            exit()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
import math,sys
p = int(math.sqrt(X))+1
for i in range(p):
    for j in range(-p,p):
        if i**5 - j**5 ==X:
            print(i,j)
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

c = []
for i in range(1, X+1):
    if i != 0 and X % i == 0:
        c.append([i, X//i])

for x1, x2 in c:
    for b in range(-1000, 1000):
        if b != 0:
            if (x1+b)**3 * (2*b+x1) + (b**2) * (x1**2 + 3*x1*b+3*(b**2)) == x2:
                print(x1+b, b)
                break

Submission status: Time Limit Exceeded

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


def main():
    x = int(input())
    # 素因数分解してユニークな因数を取る。
    insu = prime_factorize(x)
    # a^5 - b^5 も a - b も，ある因数の倍数となる。

    # a は足す一方なので，
    b_min = -int(x ** (1 / 5))
    for n in insu:
        b = b_min
        while 1:
            a = b
            while 1:
                a += n
                cand = a ** 5 - b ** 5
                if cand == x:
                    return f'{a} {b}'
                elif cand > x:
                    break
            b += 1


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

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
flag = 0
minB = -1*int(X**0.2)
for B in range(minB,10**9+1):
    Y = (X+B**5)**0.2
    if Y==int(Y):
        print(int(Y),B)
        break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

flag = False

for i in range(int(pow(x, 1/5))+1):
    a = x - i**5
    for j in range(a+1):
        if j**5 == a:
            flag = True
            break
    if flag:
        print(j, -i)
        break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

for i in range(int(x**(3/5)+1)):
    for j in range(-int((x)**(1/5))-1,int((x)**(1/5))+1):
        if i**5 - j**5 == x:
            print(i,j)
            break
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
a=0
b=0
while a**5 < x:
    a+=1
a-=1
while a**5 - b**5 != x and a**5 + b**5 != x:
    b+=1
if a**5 - b**5 == x:
    print(a,b)
else:
    print(a,b*-1)

Submission status: Time Limit Exceeded

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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
for i in range(10**8):
    if i**5 == x:
        print(i,0)
        break
    elif i**5 == x-1:
        print(i,-1)
        break
    elif i**5 == x+1:
        print(i,1)

Submission status: Time Limit Exceeded

Solution code:
from decimal import *
getcontext().prec = 100
x = Decimal(input())
i = Decimal(0)
while i*i*i*i*i<=x:
    if pow(x-i*i*i*i*i, Decimal(0.2))%Decimal(1)==0:
        print(i, -int(pow(x-i*i*i*i*i, Decimal(0.2))))
        exit()
    i += 1


while 1:
    if pow(i*i*i*i*i-x, Decimal(0.2))%Decimal(1)==0:
        print(i, int(pow(i*i*i*i+i-x, Decimal(0.2))))
    i += 1

Submission status: Time Limit Exceeded

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

sort()
sorted(reverse=true)

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

Decimal()
'''

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


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


t = int(stdin.readline().rstrip())
data = show_divisors(t)

x = data[0]
if len(data) > 2:
    x = data[1]
b = 0
while True:
    paraT = ((b + x) ** 4 + b * (b + x) ** 3 + (b ** 2)
             * (b + x) ** 2 + (b ** 3) * (b + x) + b ** 4)
    paraF = ((-b + x) ** 4 + (-b) * (-b + x) ** 3 + ((-b) ** 2)
             * (-b + x) ** 2 + ((-b) ** 3) * (-b + x) + b ** 4)
    if paraT * x == t:
        print(str(b + x) + ' ' + str(b))
        break
    if paraF * x == t:
        print(str(-b + x) + ' ' + str(-b))
        break
    b += 1

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

for a in range(0, 10**9):
    a *= a
    bb = X + a**5
    B = bb**0.2

    if isinstance(B, float):
        if B.is_integer():
            print(int(B), a)
            break

    a *= -1
    bb = X + a**5
    B = bb**0.2
    if isinstance(B, float):
        if B.is_integer():
            print(int(B), a)
            break

Submission status: Time Limit Exceeded

Solution code:
import sys

x=int(input())
a=1
while(1):
    if(a+1)**5>x:
        break
    a+=1
b=0
s=0
while(1):
    while(1):
        if(a==b):
            break
        if x%(a-b)==0:
            A=a**5
            B=b**5
            k=x-A
            if(-B==k):
                print(a,b)
                sys.exit()
            elif (B==k):
                print(a,-b)
                sys.exit()
        b+=1
    a+=1

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
a = 1
b = 0
A = []

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

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

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

print(a, b)

Submission status: Time Limit Exceeded

Solution code:
import sys

s = int(input())
#print(s)

N=10000
d=[0]*N


for i in range(N):
  d[i]=i**5
  
for i in range(N):
  for j in range(i,N):
    if (d[i] + d[j] == s) :
      print(i,-j)
      sys.exit
    elif (d[i] - d[j] == s):
      print(i,j)
      sys.exit
    elif (d[j] + d[i] == s):
      print(j,-i)
      sys.exit
    elif (d[j] - d[i] == s):
      print(j,i)
      sys.exit

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

s=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

b=int(s**(1/5))*(-1)
num=0
a=1
while True:
    try:
        f=(s+(b-num)**5)**(1/5)
        if f.is_integer():
            a=-1
            break
        f=(s+(b+num)**5)**(1/5)
        if f.is_integer():
            break
    except:
        pass
    num+=1

print(str(int(f))+' '+str(b+a*num))

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

i = 0

while abs(X-i**5) > abs(X-(i+1)**5):
  i = i + 1
  
A = i
a = i**5
j = 0

while a - j**5 != X:
  if j == 0:
    j += 1
  elif j > 0:
    j = -j
  else:
    j = -j+1
    
print(A, j)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
root5x = int(pow(x, 0.2)) + 1
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:
  rest = x // d
  if rest % 5 > 1:
    continue
  for a in range(d):
    b = a - d
    if x == a ** 5 - b ** 5:
      print(a, b)
      break
  else:
    continue
  break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
a = 0
b = 0
while a ** 5 - b ** 5 != x and a ** 5 + b ** 5 != x:
    for b in range (a+1):
        if a ** 5 - b ** 5 == x or a ** 5 + b ** 5 == x:
            break
    
    a += 1

if a ** 5 - b ** 5 == x:
    print(a, b)
else:
    print(a, -1 * b)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

CNT = 10000

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

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
ansa = 1
ansb = 1
for i in range(-10**7,10**7):
    a = (X + i**5)**(1/5)
    if isinstance(a, complex):
        pass
    else:
        a = float(a)
        if a.is_integer() == True:
            ansa = int(a)
            ansb = i
        break
print(str(-1*ansb) + ' ' + str(-1*ansa))

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=1
    b=1-x
    while 1:
        tmp = a**5-b**5
        if tmp>n and b>0:
            break
        if tmp==n:
            print(a,b)
            exit()
        a+=1
        b+=1
    a=1
    b=1-y
    while 1:
        tmp = a**5-b**5
        if tmp>n and b>0:
            break
        if tmp==n:
            print(a,b)
            exit()
        a+=1
        b+=1

Submission status: Time Limit Exceeded

Solution code:
import numpy 
x = int(input())
max = 10**9+1
flag = False
for i in range(1,max):
    if x%i == 0:
        for j in range(-i,i+1): 
            if (numpy.power(i-j,5) - numpy.power(j,5)) == x:
                print(str(i-j)+" "+str(j))
                flag = True
                break
    if flag:
        break

Submission status: Time Limit Exceeded

Solution code:
import itertools


max_num = 3000
num_list = [i for i in range(-max_num,  max_num+1)]
num_list_5 = [i ** 5 for i in num_list]
num_comb = list(itertools.combinations(num_list, 2))

x = int(input().strip())
for comb in num_comb:
    a = comb[0]
    b = comb[1]
    a5 = num_list_5[a]
    b5 = num_list_5[b]
    if a5 - b5 == x:
        print(num_list[a], num_list[b])
        break

Submission status: Time Limit Exceeded

Solution code:
import sys
x=int(input())
for a in range(x):
    for b in range(-x,x):
        if a**5-b**5==x:
            print(a,b)
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
for a in range(-1000000, 1000001):
    p = a ** 5
    l, r = -100000000, 100000001
    while r - l > 1:
        m = (l + r) // 2
        if m ** 5 <= p - x:
            l = m
        else:
            r = m
    if l ** 5 == p - x:
        print(p, l)
        exit(0)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
sign = ((1,1),(1,-1),(-1,1),(-1,-1))
isloop=True
for a in range(10**5):
    if(isloop==False):
        break
    for b in range(10**5):
        if(isloop==False):
            break
        for s1,s2 in sign:
            if(isloop==False):
                break
            a1 = s1*a
            b1 = s2*b
            if((a1**5)==(x+b1**5)):
                print(a1,b1)
                isloop=False
                break

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
def modpow(a, n, mod):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % mod
        a *= a
        a = a % mod
    return ret
i = 0
L = list()
while True:
    num = modpow(i,5,X)
    if num in L:
        j = L.index(num)
        ret = '{} {}'.format(i,j)
        print(ret)
        break
    else:
        L.append(num)
        i += 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 - 1
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:
import math

X = int(input())

def decompose(n):
	result = []
	half = math.floor(math.sqrt(n))
	i = 2
	while i <= half:
		if n % i == 0:
			result.append(i)
			n //= i
			half = math.floor(math.sqrt(n))
		else:
			i += 1
	if n > 1:
		result.append(n)
	return result

facts = decompose(X)

fact_table = {}
for f in facts:
	if f not in fact_table:
		fact_table[f] = 1
	else:
		fact_table[f] += 1

facts = list(fact_table.items())
facts.sort()

def find(num, n):
	if n >= len(facts):
		A = 0
		while True:
			B = A - num
			x = A ** 5 - B ** 5
			if x == X:
				return A, B
			elif 5 * A ** 4 - 5 * B ** 4 > 0 and x > X:
				break
			A += 1
	else:
		f, c = facts[n]
		for i in range(c + 1):
			ret = find(num, n + 1)
			if ret != None:
				return ret
			num *= f
	return None

A, B = find(1, 0)


print(A, B)

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
ans=0
a=0
while ans==0:
  A=(a**5)-x
  if A>=0:
    b=abs(A)**(1/5)
    if b==int(b):
      print(str(a)+" "+str(int(b)))
  else:
    b=abs(A)**(1/5)
    if b==int(b):
      print(str(a)+" "+str(int(-b)))
      ans=1
  a=a+1

Submission status: Time Limit Exceeded

Solution code:
import itertools


max_num = 5000
num_list = [i for i in range(-max_num,  max_num+1)]
num_list_5 = [i ** 5 for i in num_list]
num_comb = list(itertools.combinations(num_list, 2))

x = int(input().strip())
for comb in num_comb:
    a = comb[0]
    b = comb[1]
    a5 = num_list_5[a]
    b5 = num_list_5[b]
    if a5 - b5 == x:
        print(num_list[a], num_list[b])
        break

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)

    if temp!=1:
        arr.append(temp)

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

    return arr

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