eolymp
bolt
Try our new interface for solving problems
Məsələlər

Mesmerization of The Count

Mesmerization of The Count

Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB

"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

(a/b)^3 + (c/b)^3 = n

for natural numbers a, b, c, and n. For instance,

(415280564497/348671682660)^3 + (676702467503/348671682660)^3 = 9

stopped him in his tracks for a good 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

(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 n, and your job is to generate values for the natural numbers a, b, c that satisfy the first equation. When multiple solutions exist, you should report the one with the minimum possible sum a + b + c + b, such that the value of a/b is greater than or equal to the value of c/b. You may assume such a solution is unique. If you cannot find three natural numbers a, b, c such that a + b + c + b is less than 4000, you should print "No value.".

Giriş verilənləri

The input will be a sequence of lines; each line will contain a single natural number less than 10000. Input is terminated with a 0, which should not be processed.

Çıxış verilənləri

For any valid equation you find, print the equation with the appropriate values for a, b, and c. A single space should precede and follow the + and the = in the equation. When no valid equation exists, print "No value.".

Nümunə

Giriş verilənləri #1
1
9
7
6000
0
Çıxış verilənləri #1
No value.
(2/1)^3 + (1/1)^3 = 9
(5/3)^3 + (4/3)^3 = 7
(370/21)^3 + (170/21)^3 = 6000
Mənbə ACM ICPC North America - Pacific Northwest 2010