Vampire Count Kim Sang-geun
Time limit2sMemory limit128 MB
For each n under 10000, find natural a, b, c with a >= c, a^3 + c^3 = n*b^3, minimizing a + b + c + b, or print No value if the minimum exceeds 4000.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Brute force
- Solved
- No attempts yet
Problem
To fend off the attacks of the vampire Count Kim Sang-geun, you must memorize an equation of the following form.
Here , , , and are all natural numbers. For example, when the following equation holds.
(415280564497/348671682660)^3 + (676702467503/348671682660)^3 = 9
But an equation this long cannot be memorized before the Count strikes and turns you into a vampire. Fortunately, for the same there is a far shorter equation.
(2/1)^3 + (1/1)^3 = 9
Given a natural number , write a program that finds the equation that is easiest to memorize. The easiest-to-memorize equation is the one that minimizes , subject to (that is, ). The equation satisfying these conditions is always unique. If no equation has smaller than , print No value..
Input
The input consists of several test cases. Each line contains one natural number smaller than . The last line contains a single , which is not processed.
Output
For each test case, print the easiest-to-memorize equation on its own line. Print exactly one space before and after each + and = sign. If no valid equation exists, print No value..