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

Solution in Kotlin (1.3.71) (judge verdict: Time Limit Exceeded)

//package abc166.D

import java.io.*
import java.math.*
import java.util.*
import kotlin.math.*

var reader: BufferedReader = System.`in`.bufferedReader()
var writer: PrintWriter = PrintWriter(System.`out`)

fun next() = reader.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextStrings() = next().split(" ")
fun nextInts() = nextStrings().map { it.toInt() }
fun nextLongs() = nextStrings().map { it.toLong() }
fun nextDoubles() = nextStrings().map { it.toDouble() }

fun put(v: Any?) = writer.print(v)
fun puts() = writer.println()
fun puts(v: Any?) = writer.println(v)

var debug = false
fun dp(v: Any?) {
    if (debug) println(v)
}
fun dp() {
    if (debug) println()
}

fun test(case: Int, input: String, expected: String) {
    reader = input.trimIndent().reader().buffered()

    val stringWriter = StringWriter()
    writer = PrintWriter(stringWriter)

    solve()
    writer.flush()

    val actual = stringWriter.toString()

    println("[test $case]")
    if ("${expected}" == actual) {
        println("OK")
    } else {
        println("NG")
        println()
        println("expected: \"${expected}\"")
        println("actual:   \"${actual}\"")
    }
    println()
}

@Suppress("UNUSED_PARAMETER")
fun xtest(case: Int, input: String, expected: String) {}

fun main(args: Array<String>) {
    if ((args.size == 1) && (args[0] == "test")) {
        testAll()
    } else {
        solve()
        writer.flush()
    }
}

///////////////////////////////////////////////////////////

fun testAll() {
    debug = true

    test(1,
    """
    33
    """,
    "2 -1"
    )
    test(2,
    """
    1
    """,
    "0 -1")
    test(3,
    """
    918330048
    """,
    "54 -54")
}

fun pow5(value: Long): Long {
    var v = value
    var vv = v*v
    return vv * vv * v
}

fun findB(b5: Long): Long? {
    var l = 1L
    var u = b5

    while (l <= u) {
        var m = l + (u-l)/2
        var m5 = pow5(m)

        if (m5 == b5) {
            return m
        } else if (m5 < b5) {
            l = m + 1
        } else {
            u = m - 1
        }
    }

    return null
}

fun doSolve(): Pair<Long, Long> {
    val X = nextLong()

    var a = 0L
    while (true) {
        val a5 = pow5(a)
        val b5 = a5 - X
        //dp("$b5")

        if (b5 == 0L) {
            return Pair(a, 0)
        } else if (b5 > 0) {
            val b = findB(b5)
            if (b != null) {
                return Pair(a, b)
            }
        } else {
            val b = findB(-b5)
            if (b != null) {
                return Pair(a, -b)
            }
        }

        ++a
    }
}

fun solve() {
    val (a, b) = doSolve()
    put("$a $b")
}