2000 LSU Computer Science High School Programming Contest
Veteran Problem 1: Eeny Meeny (Judge Copy)

MAIN
  Home
  Schedule
  Rules
  Compile

PROBLEMS
  Novice
  Veteran
  All

  

Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.

Veteran Problem 1: Eeny Meeny (Judge Copy)

In darkest <name of continent/island deleted to prevent offense> lived a tribe called the ``Eeny Meenys''. They got this name from their way of choosing a chief for a year. It appears that a newspaper reporter visited the tribe and managed to get across a few ideas of civilization, but apparently came to an unfortunate end before finishing the job. Thus the tribe no longer had a permanent chief; the chief's term was exactly one year. At the end of that time, they ate the current chief, and chose another chief. Their method of choosing a chief was the ``Eeny meeny miny mo'' method. All eligible tribal members (women were also eligible--one of the blessings of civilization the tribe had adopted) stood in a circle, a starting place was chosen, and the chief medicine man (who was ineligible for chieftainship) went around counting out `E', `e', `n', `y', `M', `e', `e', `n', `y', `M',`i', `n', `y', `M', `o!', `E', `e', `n', `y', `M', `e', `e', `n', `y', `M', `i', `n', `y', `M', `o!', .... At every `o!', the person indicated was pushed out of the circle which then closed up and the count restarted with his neighbor (the one who would have been `E' anyway). This process continued until only one was left--the new chief.

While the chance of glory for a year makes the job of chief highly attractive to tribal members, you (possessing a computer decades before they were invented) find the brevity of the glory unappealing. You have managed to find out that the count this year will start with Mxgobgwq (a very large person). You have also been busy doing a census, and know how many people are going to show up. Unfortunately, you do not know if the count will go to clockwise or counter-clockwise. You want to find out both locations that should not be choosen (you need to make sure not to stand in either of them).

Input

Input will consist of a series of lines, each line containing the number of people who will be present. You will always assume that Mxgobgwq is in the first location. You should stop processing when you encounter a 0 for number of people. The population will never be more than 500.

Output

Output will consist of a series of lines, one for each line of the input. Each line will consist of two numbers separated by at least one space. The first number will be the place to not stand when going clockwise. The second number will be where to not stand if the direction is counter-clockwise. You should always start numbering Mxgobgwq as 1 and number the people clockwise.

Sample input

2 
3
27 
150
0

Sample output

2 2
2 3
17 12
40 112

Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.

Test Data 0

2 
3
27 
150
0

Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.

Output for Test Data 0

2 2
2 3
17 12
40 112

Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.

Test Data 1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
0

Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.

Output for Test Data 1

2 2
2 3
1 1
1 1
4 4
5 4
4 6
1 1
6 6
10 3
1 1
3 12
4 12
4 13
3 15
1 1
16 4
12 9
7 15
1 1
16 8
8 17
23 3
13 14
2 26
17 12

Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.

Test Data 2

500
1
250
499
2
33
97
333
0

Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.

Output for Test Data 2

339 163
1 1
162 90
324 177
2 2
17 18
95 4
264 71

Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.

Test Data 3

22
101
222
331
16
400
0

Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.

Output for Test Data 3

16 8
57 46
206 18
234 99
3 15
179 223

Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.



The statements and opinions included in these pages are those of the LSU Computer Science High School Programming Contest Staff only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.

© 2000 LSU Computer Science High School Programming Contest

This page last updated Fri Feb 11 21:55:29 2000.