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)

fun main(args: Array<String>) = ABC166D.main()

object ABC166D {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val X = readInt()

        val (al, be) = (1..Int.MAX_VALUE).asSequence().mapNotNull { al ->
            val al2 = al * al
            val al4 = al2 * al2
            val beta = (1..al).asSequence().mapNotNull { pb ->
                if (
                    X % al != 0
                    || ((X / al) - al4) % 5 != 0
                        ) return@mapNotNull null

                val pLeft = al2 + pb
                val pRight = ((X / al) - al4) / 5 / pb

                val mb = -pb
                val mLeft = al2 + mb
                val mRight = ((X / al) - al4) / 5 / mb
                when {
                    (pLeft == pRight) -> pb
                    (mLeft == mRight) -> mb
                    else -> null
                }
            }.firstOrNull()
            beta?.let { al to it }
        }.first()
        //////
        val D = Math.sqrt((al * al + 4 * be).toDouble()).toInt()
        val A1 = (al + D) / 2
        val A2 = (al - D) / 2
        val B1 = A1 - al
        val B2 = A2 - al
        val ans = when {
            check(A1, B1, X) -> A1 to B1
            check(A2, B2, X) -> A2 to B2
            else -> null
        }
        println("${ans?.first} ${ans?.second}")
    }

    fun check(A: Int, B: Int, X: Int) = (A * A * A * A * A - B * B * B * B * B) == X

    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}