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: Accepted

Solution code:
x = int(input())
a = 0
b = 0

for i in range(120):
    for j in range(-100, 120):
        if i**5 - j**5 == x:
            a = i
            b = j

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

Submission status: Accepted

Solution code:
#D

X=int(input())
flag=True

#B=0
for a in range(1,100):
    if a**5==X:
        flag=False
        print(a,0)
        break

#A>0>B
if flag:
    br=False
    for a in range(1,101):
        for b in range(1,101):
            if a**5+b**5==X:
                flag=False
                br=True
                print(a,-b)
                break
        if br:
            break
        
#A>B>0
if flag:
    br=False
    for b in range(1,201):
        for a in range(b+1,201):
            if X%(a-b)==0:
                if a**5-b**5==X:
                    print(a,b)
                    br=True
                    break
        if br:
            break

Submission status: Accepted

Solution code:
# coding: utf-8

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

D = make_divisors(x)
for i in D:
    for j in range(-10000,10000):
        k = j +  i
        if k**5 - j**5 == x:
            a, b = k, j
            break

print(a,b)

Submission status: Accepted

Solution code:
X = int(input())
A = 0
B = int(-X**(1/5))

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

Submission status: Accepted

Solution code:
X = int(input())
plus = [i**5 for i in range(1000)]

for num in plus:
  if abs(X - num) in plus:
    break
    
if (X - num) in plus:
  print(plus.index(num), -1*plus.index(X-num))
else:
  print(plus.index(num), plus.index(num-X))

Submission status: Accepted

Solution code:
hoge = {}
for i in range(1000):
    hoge[i] = i**5
for i in range(1000):
    hoge[-i] = -i**5
x = int(input())
for i in hoge.items():
    for j in hoge.items():
        if i[1] - j[1] == x:
            print(i[0], j[0])
            break
    else:
        continue
    break

Submission status: Accepted

Solution code:
import numpy as np

X = int(input())

A = -1000
is_finish = False
while 1:
    B = -1000
    while 1:
        if X+B**5 == A**5:
            print("%d %d"%(A,B))
            is_finish=True
            break
        if X+B**5 > A**5:
            break
        B+=1
    A+=1
    if is_finish:
        break

Submission status: Accepted

Solution code:
import itertools
import math
import sys

X = list(range(-200,201))

X_list = list(map(lambda x: x ** 5, X))

# print(X_list)

ans = int(input())

# print(X_list[0])
# print(math.sqrt(X_list[200]))
for x in itertools.combinations(X_list, 2):
  if x[0]-x[1] == ans:
      a =abs(x[0]**(1/5))
      b =abs(x[1]**(1/5))
      if x[0] < 0:
          a = a*(-1)
      if x[1] < 0:
          b = b*(-1)
    #   print(x[0],x[1])
      print(int(a),int(b))
      sys.exit()
  if x[1]-x[0] == ans:
      a = abs(x[1]**(1/5))
      b = abs(x[0]**(1/5))
      if x[1] < 0:
          a = a*(-1)
      if x[0] < 0:
          b = b*(-1)
    #   print(x[1],x[0])
      print(int(a),int(b))
      sys.exit()

Submission status: Accepted

Solution code:
import sys
X=int(input())
for i in range(10**3):
  for k in range(-10**3,10**3):
    if i**5-k**5==X:
      print(i,k)
      sys.exit()

Submission status: Accepted

Solution code:
import sys
x=int(input())
a=0
while True:
  for i in range(-64,a):
    if a**5-i**5==x:
      print(a,i)
      sys.exit()
  a+=1

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
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

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
x = int(input())
for a in range(10 ** 5):
    for b in range(-10 ** 3, 10 ** 3):
        if x == a ** 5 - b ** 5:
            print(a, b)
            sys.exit()

Submission status: Accepted

Solution code:
x = int(input())

i = -1
b = 0
judge = 0
flag = True
while flag:
    i += 1
    judge = i ** 5 - x
    if judge < 0:
        b = -1
        judge = - judge
        temp = - b ** 5
        while temp <= judge:
            if temp == judge:
                flag = False
                break
            else:
                b -= 1
                temp = - b ** 5
    elif judge == 0:
        b = 0
        break
    else:
        b = 1
        temp = b ** 5
        while temp <= judge:
            if temp == judge:
                flag = False
                break
            else:
                b += 1
                temp = b ** 5
        
print(i, b)

Submission status: Accepted

Solution code:
from sys import exit
X = int(input())
p = [0]*122
for i in range(122):
    p[i] = pow(i , 5)
for i in range(122):
    a = p[i]
    for j in range(i):
        if a-p[j] == X:
            print(i, j)
            exit()
    for j in range(i, 122):
        if a+p[j] == X:
            print(i, -1*j)
            exit()

Submission status: Accepted

Solution code:
x=int(input())
a=0
b=0
set5 = set([i**5 for i in range(1000)])
set5 = set5 | set([-i**5 for i in range(1000)])
while True:
    a += 1
    #calc = a**5 - b**5
    #if calc == x:
    #    print(str(a)+" "+str(b))
    #    break
    #else:
    #    if
    temp = (a**5-x)
    if temp in set5:
        if a**5-x < 0:
            b = -int((-temp)**(1/5)+0.01)
        else:
            b = int(temp**(1/5)+0.01)
        print(str(a)+" "+str(b))
        break

Submission status: Accepted

Solution code:
X = int(input())

A = []
for i in range(-1000, 1000):
    for j in range(-1000, 1000):
        if (i ** 5 - j ** 5) == X:
            print(i, j)
            exit()

Submission status: Accepted

Solution code:
x = int(input())
a = []

for i in range(500):
    num = i ** 5
    a.append(num)

for i in range(500):
    for j in range(i, 500):
        if a[i] - a[j] == x:
            ans = str(i) + ' ' + str(j)
            break
        elif a[i] + a[j] == x:
            ans = str(i) + ' -' + str(j)
            break
        elif a[j] - a[i] == x:
            ans = '-' + str(i) + ' -' + str(j)
            break

print(ans)

Submission status: Accepted

Solution code:
x=int(input())
for i in range(200):
    a=i
    for j in range(-200,i):
        b=j
        if a**5-b**5==x:
            am=a
            bm=b
        else:
            c=0
print(am,bm)

Submission status: Accepted

Solution code:
import itertools
x = int(input())

comb = list(itertools.product([_ for _ in range(-70, 140)],repeat=2))

for c in comb:
    a, b = c[0], c[1]
    if a**5 - b**5 == x:
        print(a, b)
        break

Submission status: Accepted

Solution code:
x = int(input())
sq = []
for i in range(10**3):
    sq.append(i**5)
    sq.append(-i**5)
b = False
for i in range(len(sq)):
    for j in range(len(sq)-i):
        if sq[-i-1]-sq[j] == x:
            if i%2 == 0:
                m = -1
            else:
                m = 1
            if j%2 == 0:
                n = 1
            else:
                n = -1
            print(m*(1000-(i//2+1)), n*(j//2))
            b = True
            break
    if b:
        break

Submission status: Accepted

Solution code:
x = int(input())
n = 100000

def binp(arr, val):
    left,right = 0,len(arr)-1
    while left <= right:
        mid = (left+right)//2
        if val==arr[mid]: return mid
        elif val>=arr[mid]: left = mid+1
        else: right = mid-1
    return 0

def binn(arr, val):
    left,right = 0,len(arr)-1
    while left >= right:
        mid = (left+right)//2
        if val==arr[mid]: return mid
        elif val>=arr[mid]: right = mid+1
        else: left = mid-1
    return 0

ap = [i**5 for i in range(n)]
an = [-(i**5) for i in range(n)]

for b in range(-n,n):
    val = x + b**5
    a = max(binp(ap, val), binn(an,val))
    if a: print(a,b) ; break

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    x = int(input())
    for i in range(-1000, 1000):
        for j in range(-1000, 1000):
            if x == (i**5-j**5):
                print(str(i)+' '+str(j))
                return


main()

Submission status: Accepted

Solution code:
import math
a=[1, 32, 243, 1024, 3125, 7776, 16807, 32768, 59049, 100000, 161051, 248832, 371293, 537824, 759375, 1048576, 1419857, 1889568, 2476099, 3200000, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176, 69343957, 79235168, 90224199, 102400000, 115856201, 130691232, 147008443, 164916224, 184528125, 205962976, 229345007, 254803968, 282475249, 312500000, 345025251, 380204032, 418195493, 459165024, 503284375, 550731776, 601692057, 656356768, 714924299, 777600000, 844596301, 916132832, 992436543, 1073741824, 1160290625, 1252332576, 1350125107, 1453933568, 1564031349, 1680700000, 1804229351, 1934917632, 2073071593, 2219006624, 2373046875, 2535525376, 2706784157, 2887174368, 3077056399, 3276800000, 3486784401, 3707398432, 3939040643, 4182119424, 4437053125, 4704270176, 4984209207, 5277319168, 5584059449, 5904900000, 6240321451, 6590815232, 6956883693, 7339040224, 7737809375, 8153726976, 8587340257, 9039207968, 9509900499, 10000000000, 10510100501, 11040808032, 11592740743, 12166529024, 12762815625, 13382255776, 14025517307, 14693280768, 15386239549, 16105100000, 16850581551, 17623416832, 18424351793, 19254145824, 20113571875, 21003416576, 21924480357, 22877577568, 23863536599, 24883200000]
x=int(input())
p=0
if x==1:
    print(0,-1)
else:
    for i in range(len(a)):
        for j in range(len(a)):
            if a[j]-a[i]==x :
                print(j+1,i+1)
                p+=1
                break
            elif a[j]+a[i]==x:
                print(j+1,-i-1)
                p+=1
                break
        if p>0:
            break

Submission status: Accepted

Solution code:
x=int(input())
n=int(x**(1/5))
a=0
b=0
for i in range(10*(n+1)):
    for j in range(-10*(n+1),10*(n+1)):
        if i**5 - j**5 == x:
            a=i
            b=j
            print(i,j)
            exit(0)

Submission status: Accepted

Solution code:
x=int(input())
a=1
while True:
    if a**5-x>0:
        for b in range(a):
            if x==a**5-b**5:
                print("{0} {1}".format(a,b))
                exit()
    elif a**5-x<0:
        b=-1
        while True:
            if b**5<a**5-x:
                break
            if x==a**5-b**5:
                print("{0} {1}".format(a,b))
                exit()
            b-=1
    else:
        b=0
        print("{0} {1}".format(a,b))
        exit()
    a+=1

Submission status: Accepted

Solution code:


a = int(input())
lister = []
dicter = dict()
for i in range(0, 121):
    lister.append(i ** 5)
    lister.append(-i ** 5)
    dicter[i ** 5] = i
    dicter[- i ** 5] = -i

for i in range(1, 121):
    no = i ** 5 - a
    if no in lister:
        print(i, dicter[no])
        break

Submission status: Accepted

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

import math

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

     num_list = []
     len_num_list = 0

     a = 0
     end = False
     while(not end):
          num_list.append(pow(a, 5))
          len_num_list += 1

          # print(a)
          # print(num_list)

          for i in range(len_num_list):
               for j in range(i, len_num_list):
                    i_5div = num_list[i]
                    j_5div = num_list[j]

                    if i_5div - j_5div == x:
                         print('{} {}'.format(i, j))
                         end = True
                         break
                    if j_5div - i_5div == x:
                         print('{} {}'.format(j, i))
                         end = True
                         break
                    if i_5div + j_5div == x:
                         print('{} {}'.format(i, j * (-1)))
                         end = True
                         break
                    if j_5div + i_5div == x:
                         print('{} {}'.format(j, i * (-1)))
                         end = True
                         break

          a += 1


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x = int(input())

a = 0

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)

while True:
    for divisor in divisors:
        b = a - divisor
        if a**5-x == b**5:
            break
    else:
        a += 1
        continue
    break

print(a, b)

Submission status: Accepted

Solution code:
x = int(input())

xset = set([])

for i in range(10000):
    xset.add(i**5)
    xset.add(-i**5)

for xx in xset:
    if xx+x in xset:
        a5 = xx+x
        b5 = xx

if a5 < 0:
    a = -pow(-a5, 0.2)
else:
    a = pow(a5, 0.2)

if b5 < 0:
    b = -pow(-b5, 0.2)
else:
    b = pow(b5, 0.2)

print(int(a), int(b))

Submission status: Accepted

Solution code:
from sys import stdin
import random

#a , b = 81,79
#x = a**5 - b**5
'''
while x < 1 or x > 10**9:
    a = random.randint(-100, 100)
    b = random.randint(-100, 100)
    x = a**5 - b**5
'''
#print(a,b,x)
x = int(stdin.readline().rstrip())

fivelist = []

i = 0
while True:
    n = i**5
    # print(i,n)
    if n > 2*(10**15):
        break
    fivelist.append(n)
    i += 1


a = 0
b = 0
ans = False
for i in range(len(fivelist)):
    for j in range(len(fivelist)):
        if x == (fivelist[i] - fivelist[j]):
            a, b = i, j
            ans = True
            break
        if x == (-fivelist[i] - fivelist[j]):
            a, b = -i, j
            ans = True
            break
        if x == (fivelist[i] + fivelist[j]):
            a, b = i, -j
            ans = True
            break
        if x == (-fivelist[i] + fivelist[j]):
            a, b = -i, -j
            ans = True
            break
    if ans:
        break

print("{} {}".format(a, b))

Submission status: Accepted

Solution code:
x = int(input())

is_found = False
for i in range(-500, 501):
    for j in range(-500, 501):
        if i**5 - j**5 == x:
            print(i, j)
            is_found = True
        if is_found:
            break
    if is_found:
        break

Submission status: Accepted

Solution code:
def f(x):
    div = 1
    while div * div <= x:
        if x % div == 0:
            for a in range(0, int((x // div) ** 0.25) + 2):
                b = a - div
                if a ** 5 - b ** 5 == x:
                    return a, b

            opp_div = x // div
            for a in range(0, int((x // opp_div) ** 0.25) + 2):
                b = a - opp_div
                if a ** 5 - b ** 5 == x:
                    return a, b
        div += 1


def main():
    x = int(input())
    a, b = f(x)
    print(a, b)


main()

Submission status: Accepted

Solution code:
x = int(input())
pow5 = [i**5 for i in range(10**3)]
powp = []
pown = []
for i in range(10**3):
    powp.append(pow5[i])
    pown.append(-pow5[i])

for i, ii in enumerate(pow5):
    for j, ji in enumerate(powp):
        if ii - ji == x:
            # print('pp')
            print(i, j)
            exit()
    for j, ji in enumerate(pown):
        if ii - ji == x:
            # print('p1')
            print(i, -j)
            exit()

Submission status: Accepted

Solution code:
X = int(input())
for A in range(-1001,1001):
    for B in range(-1001,1001):
        if A**5 - B**5 == X:
            print(A,B)
            exit(0)

Submission status: Accepted

Solution code:
x=int(input())
l=[]

for i in range(300):
    a=i**5
    l.append(a)
    l.append(-a)
        

for j in l:
    for k in l:
        aa=j-k
        if j!=k and aa==x:
            ans=[]
            for z in [j,k]:
                aaa=abs(z)**(1/5)
                if z>=0:
                    ans.append(int(aaa))
                else:
                    ans.append(int(-aaa))
            print(*ans)                
            exit()

Submission status: Accepted

Solution code:
x = int(input())
a=0
f=False
while(1):
    b=a
    while(1):
        t = a**5-b**5
        if t==x:
            f=True
            break
        if t>x:
            break
        b-=1
    if f:break
    a+=1
print(a,b)

Submission status: Accepted

Solution code:
import math
x = int(input())
b = 0
ans = []
while True:
    n = x - b**5
    if n < 0:
        break
    a = int(math.pow(n, 1/5))
    if a**5 == n:
       ans.append(a)
       ans.append(-b)
       break
    b += 1

if len(ans) != 0:
    print(*ans)
else:
    b = 0
    while True:
        n = x + b**5
        a = int(math.pow(n, 1/5))
        if a**5 == n:
           ans.append(a)
           ans.append(b)
           break
        b += 1
    print(*ans)

Submission status: Accepted

Solution code:
import math

if __name__ == '__main__':
    x = int(input())
    limit = math.ceil(x ** 0.2) + 100
    count = 0
    for a in range(limit):
        if a ** 5 < x:
            # -
            for b in range(0, -limit, -1):
                if a ** 5 - b ** 5 == x:
                    print(a, b)
                    exit(0)
        else:
            for b in range(limit):
                if a ** 5 - b ** 5 == x:
                    print(a, b)
                    exit(0)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
# 約数列挙
def find_divisor(n):
    divisors=[]
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            if i*i!=n:
                divisors.append(n // i)
    return divisors


def main():
    X=I()
    S=set()
    for i in range(10**5):
        S.add(i**5)
        S.add(-i**5)
    for s in S:
        if(X-s in S):
            B=int(pow(abs(X-s),1/5))
            if(X-s<0):
                B*=-1
            A=int(pow(abs(s),1/5))
            if(s<0):
                A*=-1
            print(A,-B)
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
x = int(input())
finished = False
# b >= 0 check
a = max(0,int(math.pow(x,0.2)) - 1)
while a**5 - (a-1)**5 <= x:
    tmp = a**5 - x
    if tmp < 0:
        a += 1
        continue
    b = int(math.pow(tmp,0.2))
    if a**5 - b**5 == x:
        finished = True
        print(a,b)
        break
    a += 1
if not finished:
    a = 1
    while a**5 < x:
        tmp = x - a**5
        b = int(math.pow(tmp,0.2))
        if a**5 + b**5 == x:
            finished = True
            print(a,-b)
            break
        a += 1

Submission status: Accepted

Solution code:
import math

def f(X):
    for i in range(1, int(math.sqrt(X)) + 1):
        if X%i == 0:
            ret = f2(X, i)
            if ret != None:
                return (ret+i, ret)

            ret = f2(X, X//i)
            if ret != None:
                return (ret+X//i, ret)


def f2(X, d):
    d2 = X//d

    v1 = 0
    v2 = math.ceil((d2/5)**.25)
    
    while v1+1 < v2:
        v = (v1+v2)//2
        a, b = v+d, v
        y = a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4
        if y == d2:
            return v

        if y < d2:
            v1 = v
        else:
            v2 = v

    return None


def g(X):
    for a in range(int(X**.2)):
        b = int((X-a**5)**.2 + 0.5)
        if a**5 + b**5 == X:
            return (b, -a)


X = int(input())
ans = f(X)
if ans == None:
    ans = g(X)

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

Submission status: Accepted

Solution code:
import sys

x = int(input())

for i in range(120):
  for j in range(-63, 119):
    if ( i**5 - j**5) == x:
      print(i, j)
      sys.exit(0)

Submission status: Accepted

Solution code:
import sys
x=int(input())
for i in range(1,1001):
    for j in range(-1000,1001):
        if i**5-j**5==x:
            print(i,j)
            sys.exit()

Submission status: Accepted

Solution code:
x = int(input())
for i in range(300):
  for j in range(-300,300):
    if i >= j:
      a = i**5 - j**5
      if a == x:
        b = i
        c = j
print(b, c)

Submission status: Accepted

Solution code:
x=int(input())


for a in range(-200,200):
    for b in range(-200,200):
        if x == a**5-b**5:
            ans = [a,b]
            print(a,b)
            exit()

Submission status: Accepted

Solution code:
X = int(input())
y = {pow(i, 5):i for i in range(100000)}

for val in y:
  if (X + val) in y:
    print(y[X + val], y[val])
    exit()
  elif (X - val) in y:
    print(y[X - val], -1 * y[val])
    exit()
  elif -1 * (X + val) in y:
    print(-1 * y[X + val], y[val])
    exit()
  elif -1 * (X - val) in y:
    print(-1 * y[X - val], -1 * y[val])
    exit()

Submission status: Accepted

Solution code:
import math

def is_square(integer):
    root = math.sqrt(integer)
    return integer == int(root + 0.5) ** 2

x = int(input())

divisors = []

for i in range(1, math.ceil(math.sqrt(x)) + 1):
    if x % i == 0:
        divisors.append(i)
        divisors.append(-i)
        divisors.append(x//i)
        divisors.append(-x//i)

dpPairs = []

for delta in divisors:
    if ((x // delta) - delta**4) % 5 != 0:
        continue
    disc = delta**4 + 4 * (x // delta - delta**4) / 5
    if disc < 0 or not is_square(disc):
        continue
    sqdisc = int(math.sqrt(disc) + 0.5)
    if delta ** 2 % 2 != sqdisc % 2:
        continue
    dpPairs.append((delta, (- delta ** 2 - sqdisc) // 2))
    dpPairs.append((delta, (- delta ** 2 + sqdisc) // 2))

for (delta, prod) in dpPairs:
    disc = delta ** 2 + 4 * prod
    if disc < 0 or not is_square(disc):
        continue
    sqdisc = int(math.sqrt(disc) + 0.5)
    if delta % 2 != sqdisc % 2:
        continue
    b = (- delta + sqdisc) // 2
    a = b + delta
    print(a, b)
    break

Submission status: Accepted

Solution code:
x = int(input())
nums = []
i = 0
while i ** 5 <= 10 ** 14:
    nums.append(i ** 5)
    i += 1

for i in range(len(nums)):
    a5 = nums[i]
    for j in range(len(nums)):
        b5 = nums[j]
        if x == a5 - b5:
            print(i, j)
            exit()
        if x == a5 + b5:
            print(i, -j)
            exit()

Submission status: Accepted

Solution code:
x = int(input())
l = []
for i in range(150,-150,-1):
    l.append(i**5)
for i in range(299):
    for j in range(300):
        if l[i] - l[j] == x:
            print(150-i,150-j)
            exit()

Submission status: Accepted

Solution code:
from itertools import combinations
import numpy as np
import math
X = int(input())
if X == 0:
    print(1, 1)
    exit()

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

def judge(a, b):
    right = a ** 4 + a ** 3 * b + a ** 2 * b ** 2 + a * b ** 3 + b ** 4
    if (a - b) * right == X:
        return True
    else:
        return False

prime = prime_factorize(X)
cand = []
if len(prime) == 1:
    cand = prime
else:
    for r in range(1, len(prime)):
        for i in list(combinations(prime, r)):
            tmp = np.prod(np.array(list(i)))
            if tmp * tmp <= X:
                cand.append(tmp)
    cand = set(cand)

for c in cand:
    for a in range(0, int(math.sqrt(X)) + 1)[::-1]:
        b = a - c
        if judge(a, b):
            print(a, b)
            exit()

Submission status: Accepted

Solution code:
x = int(input())
a = 0
for i in range(-500,500):
    for j in range(-500,500):
        if i**5 - j**5 == x:
            a = [i,j]
            break
print(a[0],a[1])

Submission status: Accepted

Solution code:
X=int(input())
A = []
a=0
while a**5 - (a-1)**5 < 10.0**9:
    A.append(a**5)
    a+=1

for i, a_5 in enumerate(A):
    for j, b_5 in enumerate(A[i+1:]):
        if b_5 - a_5 == X:
            print(str(i+j+1) + ' ' + str(i))
            exit()
        elif b_5 + a_5 == X:
            print(str(i+j+1) +' ' + str((-1)*i))
            exit()

Submission status: Accepted

Solution code:
X = int(input())
a = -1000
b = -1000
for i in range(2001):
    for k in range(2001):
        if (a+i)**5 - (b+k)**5 == X:
            print(a+i,b+k)
            break
    else:
        continue
    break

Submission status: Accepted

Solution code:
input = raw_input

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: # choufuku
                divisors.append(n//i)
    # divisors.sort()
    return divisors

def f(x, d):
    out = (x+d) ** 5 - x ** 5
    return out

ds = make_divisors(x)
#ds = ds1 + [-d for d in ds1]
#print("ds", ds)

found = False
for d in ds:
    if found:
        break

    d0 = d
    if d0 % 2 == 0:
        b = -d0 // 2
    else:
        b = -d0 // 2 + 1

    while True:
        aa = b+d
        bb = b
        ret = f(b, d)
        #print(aa, bb, d, ret)
        
        if x == ret:
            found = True
            a = b+d
            b = b
            break
        elif ret > x:
            break
        b += 1

    if found:
        break

    #b = -1
    if d0 % 2 == 0:
        b = -d0 // 2
    else:
        b = d0 // 2 - 1

    while True:
        aa = b+d
        bb = b

        ret = f(b, d)
        #print(aa, bb, d, ret)
        
        if x == ret:
            found = True
            a = b+d
            b = b
            break
        elif ret > x:
            break
        b -= 1

    if found:
        break

    d0 = d
    d = -d
    
    if d0 % 2 == 0:
        b = d0 // 2
    else:
        b = d0 // 2 + 1

    while True:
        aa = b+d
        bb = b
        ret = f(b, d)
        #print(aa, bb, d, ret)
        
        if x == ret:
            found = True
            a = b+d
            b = b
            break
        elif ret < x:
            break
        b += 1

    if found:
        break

    if d0 % 2 == 0:
        b = d0 // 2
    else:
        b = d0 // 2 - 1
    while True:
        aa = b+d
        bb = b

        ret = f(b, d)
        #print(aa, bb, d, ret)
        
        if x == ret:
            found = True
            a = b+d
            b = b
            break
        elif ret < x:
            break
        b -= 1


assert found
print("%d %d" % (a, b))