Problem H
Morning Walk!
Input: Standard Input
Output: Standard Output
Many people walks in the morning to keep fit. But morning walks can be strange for people who knows mathematics pretty well. That is what has happened to Peter who loves mathematics and loves to walk in the morning.
Peter starts walking from a fixed point M. He walks s1 steps towards a certain direction, turns left or right and then walks s2 steps to reach another place N. At N he turns left or right and walks s3 steps in a straight line and then turns left or right and walks s4 steps in that direction and reaches another place P. At P he turns left or right walks s5 steps in the same direction and then turns left or right and then he again walks s6 steps to reach point M from where he started walking. The next morning Peter decides to walks less, so from M he walks at the direction of N and after exactly s7 steps he reaches N. From N he walks towards the direction P and after s8 steps he reaches point P and from P he walks towards point M. After walking exactly s9 steps he reaches point M again.
But after walking he becomes very exhausted and forgets his walking directions or the location of N and Q. He only remembers that he has walked total S steps on the second morning. For simplification you can assume the following things:
(a) At each step Peter covers exactly the same distance.
(b) If peter turns left or right is walking direction changes exactly 90 degree.
(c) While turning only the direction of Peter changes, his position remains the same. Turning left or right is not considered as a step.
(d) For the first morning assume that s1, s2, s3, s4, s5, s6≥0. Also assume that M, N and P are three different point and not collinear.
Given the value of S, your job is to find possible values of s7, s8 and s9.
Input file contains at most 125 lines of inputs. Each line contains an integer S(0<S ≤ 80000). Input is terminated by a line containing a single zero, which should not be processed.
For each line of input produce two or more line of output. The first line should contain the serial of output. The next lines should contain possible values of s7, s8 and s9. Please note than you should print only those solutions where s7 ≤ s8 ≤ s9. If there is more than one solution then print them in the ascending order of s7. If there is still a tie then print in the ascending order of S8. If no valid values of s7, s8 and s9 is found print the line “Peter has Forgotten Everything” instead. Look at the output for sample input for details.
10 12 13 100 50002 0 |
Case 1: Peter has Forgotten Everything Case 2: 3 4 5 Case 3: Peter has Forgotten Everything Case 4: 17 39 44 18 41 41 26 26 48 29 29 42 32 34 34 Case 5: 5435 22126 22441 8696 17225 24081 12926 14249 22827 16305 16376 17321 |
Problem setter: Shahriar
Manzoor
Special Thanks: Derek
Kisman