Woburn Challenge 2002 - Suicidal

Problem 2: Klingon Roulette

As Gandalf hit the walls reeling from yet another shot from Saruman's magic staff, he noticed that they moved to a large room, with shiny violet walls. Immediately he knew what had taken place, but it was too late - with one movement of his staff, Saruman had shut the door.

What awaited Gandalf was an old wizard challenge, known as the Klingon Roulette. Gandalf would be placed in one corner, Saruman in another. They would shoot a fire ball, one at a time, which would then proceed to ricochet off the shimmering violet walls. Gandalf felt his power fading, so he knew his yellow flaming ball would only last about one billion (1,000,000,000) standard life times.

The contest was won when only one man was left standing. Gandalf focused to try to foresee the path of the ball…

Given a rectangular room of dimensions A x B x C, A, B, C ≤ 2,147,483,647, and given that Gandalf fired his shot at an angle of 45 degrees to the horizontal and vertical from corner #1, print out which corner would be hit first, or, if no corner is hit, print out SENILE.

The fire ball travels at a speed such that 1 unit is traversed in one life time. The corners are labelled in clockwise manner - (0, 0, 0) is 1, (0, B, 0) is 2, (A, B, 0) is 3, (A, 0, 0) is 4, (0, 0, C) is 5, (0, B, C) is 6, (A, B, C) is 7 and (A, 0, C) is 8.

You may also like to know that Gandalf can do this problem using a signed 32-bit integer for his calculations.

Input

Each test case consists of a line with 3 integers - A, B, and C.
There will be multiple test cases; the last test case will simply have A, B, C = -1.

Output

Print which corner would be hit first, or SENILE.

Sample Input

1 1 1
-1 -1 -1

Sample Output

7

All Submissions
Best Solutions


Point Value: 25
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 09, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

It's quiet in here...