eolymp
bolt
Try our new interface for solving problems
Problems

Mesmerization of The Count

Mesmerization of The Count

\includegraphics{https://static.e-olymp.com/content/d3/d36cb4b9dc96a683e2478ff7fce1d007a48786de.jpg} "Sesame Street’s" The Count has gone bad. He has escaped the hard-scrabble New York streets where he gained his fame and now haunts Oregon, surprising and killing unwary programmers throughout the state. Only one defense has been found: he is mesmerized by equations of the form \textbf{(a/b)^3 + (c/b)^3 = n} for natural numbers \textbf{a}, \textbf{b}, \textbf{c}, and \textbf{n}. For instance, \textbf{(415280564497/348671682660)^3 + (676702467503/348671682660)^3 = 9} stopped him in his tracks for a good \textbf{20} minutes, giving mathematician Henry Dudeney enough time to escape a certain death. Unfortunately, large numbers like this are too hard to memorize, so shorter ones such as \textbf{(2/1)^3 + (1/1)^3 = 9} are better. Each such equation is only good for one mesmerization, so your job is to write a program that will generate new such equations. In particular, you will be given \textbf{n}, and your job is to generate values for the natural numbers \textbf{a}, \textbf{b}, \textbf{c}that satisfy the first equation. When multiple solutions exist, you should report the one with the minimum possible sum\textbf{a + b + c + b}, such that the value of \textbf{a/b} is greater than or equal to the value of \textbf{c/b}. You may assume such a solution is unique. If you cannot find three natural numbers \textbf{a}, \textbf{b}, \textbf{c} such that \textbf{a + b + c + b} is less than \textbf{4000}, you should print "\textbf{No value.}". \InputFile The input will be a sequence of lines; each line will contain a single natural number less than \textbf{10000}. Input is terminated with a \textbf{0}, which should not be processed. \OutputFile For any valid equation you find, print the equation with the appropriate values for \textbf{a}, \textbf{b}, and \textbf{c}. A single space should precede and follow the \textbf{+} and the \textbf{=} in the equation. When no valid equation exists, print "\textbf{No value.}".
Time limit 1 second
Memory limit 64 MiB
Input example #1
1
9
7
6000
0
Output example #1
No value.
(2/1)^3 + (1/1)^3 = 9
(5/3)^3 + (4/3)^3 = 7
(370/21)^3 + (170/21)^3 = 6000
Source ACM ICPC North America - Pacific Northwest 2010