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:
from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで

def check(a,b,X):
  if a**5-b**5 == X:
    return 1
  else:
    return 0
  
def check2(a,b,X):
  if (a <= b+X) and (a > 0):
    return 1
  else:
    return 0

X = inp()
A = 0
tmp = 0
while 1:
  B = 1
  if A**5>X:
    need = 0
  else:
    need = 1
  reverse = 0
  if check(A,B,X):
    print(str(A)  + " " + str(B))
    break
  else:
    while 1:
      if B < A and A-X <= B:
        if check(A,B,X):
          print(str(A)  + " " + str(B))
          tmp = 1
          break
      else:
        break
      if reverse == 0 and need:
        B = (-1)*B
        reverse = 1
      elif reverse == 1:
        B = (-1)*B
        B = B + 1
        reverse = 0
  A += 1
  if tmp:
    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

L = make_divisors(X)
flag = 0
for C in L:
    Y = X//C
    for A in range(Y+1):
        B = A-C
        if A**4 + A**3*B + A**2*B**2 + A*B**3 + B**4 == Y:
            print(A,B)
            flag = 1
        if flag==1:
            break
    if flag==1:
        break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
plus=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71, \
73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173, \
179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281, \
283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409, \
419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541, \
547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659, \
661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809, \
811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941, \
947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069, \
1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223, \
1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373, \
1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511, \
1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657, \
1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811, \
1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987, \
1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129, \
2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287, \
2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423, \
2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617, \
2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741, \
2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903, \
2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079, \
3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257, \
3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413, \
3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571]

#plus=list(map(int,plus.split()))
def factorization(num):
  if num == 1:
    return [1]
  factor = []
  while num > 1:
    for i in range(500):
      k = plus[i]
      if num % k == 0:
        factor.append(k)
        num = int(num//k)
        break
  return factor
  
x=int(input())
a=0
b=0
a_b=0
y=factorization(x)
len_y=len(y)
z=set(y)


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

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

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

Submission status: Time Limit Exceeded

Solution code:
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:
x = int(input())
x_mod = x % 5
i = 0
j = 10**5
while True:
    if i - (i - x_mod) == x_mod and i ** 5 - (i-x_mod)**5 == x:
        print(i, i-x_mod)
        break
    if j - (j - x_mod) == x_mod and j ** 5 - (j-x_mod)**5 == x:
        print(j, j-x_mod)
        break
    i += 1
    j += 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:
        B5 = B**5
        if X+B5<0:
            B = B+1
            continue
        A_principle = (X+B5)**(1/5)
        if (A_principle-(A_principle//1))==0:
            print(str(int(A_principle))+" "+str(B))
            break
        B = B+1

if __name__ == '__main__':
    main()

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

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

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

        a = a + 1

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:
# 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 += 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:
            pass
        
    elif a**5 - b**5 == x:
        print(a,b)
        break

    else:
        print(a,-b)
        break

Submission status: Time Limit Exceeded

Solution code:
import sys
a=int(input())
i=1
j=1
t=True
while i**5<=a:
  if a-i**5>=0:
    if int((a-i**5)**0.2)==(a-i**5)**0.2:
      print(i,int((-1)*(a-i**5)**0.2))
      sys.exit()
  else:
    if int((-a+i**5)**0.2)==(-a+i**5)**0.2:
      print(i,int((-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:
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):
      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:
X = int(input())
List = [(A,B) for A in range(X//2+1) for B in range(-X//2,X//2) if A**5 - B**5 == X]

print(*List[0])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

stack = [[0,0]]
i = 0
def bfs(a,b):
    global stack
    global X
    
    if a**5 - b**5== X:
        return True
    
    elif a**5 - b**5 > X:
        stack.append([a,b+1])
        stack.append([a-1,b])
        return False
    elif a**5 - b**5 < X:
        stack.append([a+1,b])
        stack.append([a,b-1])
        return False

while len(stack) > i:
    if bfs(stack[i][0],stack[i][1]):
        print(str(stack[i][0]) +" "+str(stack[i][1]))
        break
    
    i+=1

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:
    A = s 
    B = s - diff
    xx = A ** 5 - B ** 5
    if xx == X:
        break
    elif xx > X:
        s = s //2
    else:
        s =  (3*s) //4
print(int(A),int(B))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

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

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

print(a, b)

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 は正でなくては，xが負になっちゃう。

    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:
x = int(input())
a = 2
b = 0
A = []
A.append(1 ** 5 - x)

while True:
    if (a + 1) ** 5 - 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:
X=int(input())
for B in range(-10**8,10**8):
    if type((X+B**5)**0.2)!=complex:
        if (X+B**5)**0.2==int((X+B**5)**0.2):
            print(int((X+B**5)**0.2), B)
            break

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
for A in range(-X,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:
x=int(input())

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

a=prime_factorize(x)

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

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
Ans=[]
for n in range(65):
    for n1 in range(65):
        n2=n**5+n1**5
        if n2 == X:
            Ans.append(n)
            Ans.append(-1*n1)
            break

if len(Ans)==0:
    for n3 in range(80,3000):
        for n4 in range(n3):
            n2=n3**5-n4**5
            if n2 == X:
                Ans.append(n3)
                Ans.append(n4)
                break

print(Ans[0],Ans[1])

Submission status: Time Limit Exceeded

Solution code:
import math
x = int(input())
b = 0

def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    if x-b5 >= 0:
        calc(-b, -b5)
    b += 1

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
ans=0
a=0
while ans==0:
  A=(pow(a,5))-x
  if A>=0:
    b=pow(A,(1/5))
    if b==int(b):
      print(str(a)+" "+str(int(b)))
  else:
    b=pow(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 sys
X = int(input())
S = int(X ** (1/5) + 1)

for i in range(10000):
    for j in range(10000):
        a = i ** 2
        b = j ** 2
        c = i * j
        if (i - j) * (a * (a ** 2 + c + b) + b * (c + b)) == X:
            print(i,j)
            sys.exit()
        elif (i + j) * (a * (a ** 2 - c + b) + b * (-c + b)) == X:
            print(i,-j)
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""


sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    x = int(input())
    for a in range(-10000, 10000):
        for b in range(-1000, 1000):
            if a**5 - b ** 5 == x:
                print(a, b)
                sys.exit()

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys


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

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


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect

D = 10000

X = int(input())

L2 = [i for i in range(-D, D)]
L = [i**5 for i in L2]

idx = bisect.bisect_left(L, X)-1

B = L[:idx]
A = L[idx:]

for a in A:
    for b in B:
        if a - b == X:
            break
    else:
        continue
    break

print(L2[L.index(a)], L2[L.index(b)])

Submission status: Time Limit Exceeded

Solution code:
import math
X=int(input())
def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%1==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    return divisors

M=make_divisors(X)

p=math.sqrt(X)
p=int(p)
for i in M:
    for k in range(p+1):
        A=k
        B=A-i
        if A**5-B**5==X:
            print(A,B)
            break

Submission status: Time Limit Exceeded

Solution code:
x=int(input())

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

a=prime_factorize(x)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
for i in range(-10000,10000,1):
    for j in range(-10000,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())

x=int(X**(1/5))
#print(x)
for i in range(-X,X):
    for j in range(i-x-1,i+x+1):
        if(i**5-j**5==X):
            print('{} {}'.format(i,j))
            exit()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A = 1
K = 1
while K < X:
    A += 1
    K = A ** 5
S = A - 1
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:
import math

x = int(input())

b = -100

while True:
    if x+b**5 > 0:
        if math.pow((x+b**5), 0.2).is_integer():
            print(int(math.pow((x+b**5), 0.2)), b)
            exit()
        
    b += 1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
A=X**(1/5)
A=int(A)
A=A-1
fact=True
while fact==True:
    A=A+1
    B=abs(A**5-X)**(1/5)
    B=int(B)
    if A**5-B**5==X or A**5+B**5==X:
        fact=False
    

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

Submission status: Time Limit Exceeded

Solution code:
# 2020/05/03
# AtCoder Beginner Contest 166 - D

# Input
x = int(input())

# Calc
eflg = False
for a in range(10**8):
    wk_a = a ** 5
    b = 0
    sav = 10 ** 10
    for b in range(10**8):
        val_1 = wk_a - (b ** 5)
        val_2 = wk_a - (-b ** 5)

        if val_1 == x:
            ans1 = a
            ans2 = b
            eflg = True
            break

        if val_2 == x:
            ans1 = a
            ans2 = -b
            eflg = True
            break
        
        sav = abs(val_2) - x

        if sav > x:
            break

    if eflg == True:
        break

# Output
print(ans1, ans2)

Submission status: Time Limit Exceeded

Solution code:
import sys, math


input = sys.stdin.readline

gets = lambda: input().rstrip()
getn = lambda: int(input())
getmul = lambda: (int(i) for i in input().split())
getlist = lambda: [int(i) for i in input().split()]

x = getn()

start = int(x ** (1 / 4))
solved = False

b = start
while True:
    # print(b)
    b5 = b ** 5
    a5 = x + b5
    a = a5 ** (1 / 5)
    # print(b5, a5, a)

    try:
        a = int(a)
        if a5 == a ** 5:
            print(int(a), b)
            solved = True
    except:
        pass

    if solved:
        break
    a5 = x - b5
    a = a5 ** (1 / 5)
    try:
        a = int(a)
        if a5 == a ** 5:
            print(int(a), -b)
            solved = True
    except:
        pass

    if solved:
        break

    b += 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def pow(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 0

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

i = 0
ii = 0

while True:
    if pow(i,5)> n:
        i -= 1
        while True:
            if pow(i,5) - -(pow(ii,5)) == n:
                break
            else:
                ii+=1
        break
    else:
        i+=1

print(i,-ii)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
res1 = 0
res2 = 0
res = 0
i = 1 
j = 0
jmem = 1000
trouve = 0
while i < x:
    j = 0
    jmem = 1000
    while j < x:
        res1 = i**5
        res2 = j**5
        res = res1 - res2
        if res == x:
            trouve = 1
            break
        if j > 0:
            if res < x:
                jmem = j
                j += 1
            elif res > x:
                jmem = j
                j -= 1
        elif j <= 0:
            if res > x:
                if j+1 == jmem:
                    break
                jmem = j
                j += 1
            elif res < x:
                if j-1 == jmem:
                    break
                jmem = j
                j -= 1
        #print(i,j)
        
    if trouve: 
        break
    else:
        i += 1

print(i, j)

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)
    flag = True

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

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

        a = a + 1

Submission status: Time Limit Exceeded

Solution code:
x=int(input())

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

a=prime_factorize(x)

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

Submission status: Time Limit Exceeded

Solution code:

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 = 0
    b = -q1
    f = func(a, b)
    while f != x:
        a += 1
        b += 1
        f = func(a, b)
    print("{} {}".format(a, b))


        
submit()

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
a=32
b=0
while x < a**5:
    a=a//2
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:
X=int(input())
i=0
while i >=0:
    for j in range(-100,101):
        if i**5-j**5==X:
            print(str(i)+" "+str(j))
            break
    else:
        i=i+1
        continue
    break