-->
当前位置:首页 > 题库

PROGRAMMING:Yet Another Stones Game

Luz5年前 (2021-05-10)题库400
One day, Little Gyro and Derrick are playing a game with stones again.
There are $$N$$ ($$N$$ is always an even number) piles of stones. The $$i$$-th pile contains $$a_ i$$ stones.
In one's turn, the player should choose exactly $$\frac{N}{2}$$ non-empty piles and take any positive number of stones away for each pile he chooses. That means the player can remove stones within a different number from all the selected piles in a single turn.
And in this game, suppose that the two players, Little Gyro and Derrick, are all very clever. Little Gyro always takes first. The person who cannot make a move loses the game.
Now given the number of the stones of $$N$$ piles, if both of them play the game optimally, your job is to tell who will win the game.
### Input Specification:
There are multiple test cases. The first line of input contains an integer $$T$$, indicating the number of test cases. For each test case:
The first line contains an one integer $$N$$ (2 ≤ $$N$$ ≤ 50), indicating the number of the piles.
The second line contains $$N$$ numbers $$a_ 1$$, $$a_ 2$$,……, $$a_ n$$ (1 ≤ $$a_ i$$ ≤ 50), indicating the number of the stones in the $$i$$-th pile.
### Output Specification:
For each case, output "Happy Little Gyro"(without quotes) if Little Gyro wins the game, Otherwise, output "Sad Little Gyro"(without quotes).
### Sample Input:
```in
two
two
8 8
four
3 1 4 1
```
### Sample Output:
```out
Sad Little Gyro
Happy Little Gyro
```







answer:If there is no answer, please comment
First, consider the following two situations:
1. If a pile of stones is emptied by person1, then person2 can empty all the N / 2 piles to make person1 face the situation of less than N / 2 piles
2. When the N pile of stones can be divided into two parts (such as: 1,2,1,2) which are mirror images of each other, the successor can imitate the operation of the forerunner until the forerunner empties at least one pile of stones, and the situation shifts to the previous possibility
Therefore, if there are no more than N / 2 piles of stones in the pile, and the number of stones is the least, the forerunner can take the next N / 2 pile of stones after sorting as the first n / 2 pile of stones to win. If this condition is not met, no matter how the forerunner takes, the latter can win.