Previous examination Questions Monk wits time limit: 1.0s memory Limit: 256.0MB problem description In ancient funeral activities often asked the monks practice. At the end of the ceremony, there are sometimes "monk wits" fun programs to relieve the oppressive atmosphere.
The program is in the following steps: First use grain (usually rice) on the ground "painting" a number of steps (indicating the N-level pagoda). There are also a number of small monks randomly "stand" on a certain step. The highest level of stairs must stand people, others arbitrarily. (as shown in 1)
The two masters of the game commanded a small monk to go up the steps of any level, but will be standing on the high steps of the little monk block, can not be crossed. Neither of the two young monks can stand on the same steps, nor move to the lower steps.
The two wizards take turns issuing instructions, and eventually all the young monks will be squeezed in high steps, and can no longer move upward. When it was the master's turn to be unable to move on, the master conceded that the game was over.
For the known number of steps and the location of the small monk, please calculate how the first-order mage should make the decision to win. Input format input data is a row of n integers separated by spaces, indicating the location of the small monk. The step number is counted from 1, so the last little monk's position is the total number of steps. (n<100, number of steps <1000) The output format output is a line of two integers separated by a space: a B, which means to move the small monk in position a to position B. If there is more than one solution, the output of a small solution of a value, if no solution is output-1. Sample Input 1 5 9 Sample Output 1 4 Sample input 1 5 8 10 Sample Output 1 3
Nim game. It is important to note that there is a need to divide two into a group, where the interval is the number of stones. such as 1 5 8 10. 1-5,8-10 such points (5-8 is not counted as a heap of stones, this stone in the game to win the problem of no practical effect). If it is an odd number, the last grouping is 0 stones.
This translates into a similar situation to the Nim game, except that the number of Nim pebbles may be less, and the number of pebbles here may be more (because when the change is 5-8, it is the equivalent of 1-5 of these stones more), but the strategy is the same, is when you face the unbalanced situation when you will win (all values also or not 0 , the same number of all heap binary indices is not an even number), your goal is to turn the state into a balanced situation (all values are also 0, and all heap binary indices have the same number of even numbers)
There is also a need to pay attention to the output of the first step, you can change the distance of 1-5, that is, reduce the spacing, can also change the distance of 5-8, that is, expand the spacing.
Previous examination Questions Monk Wits (game)