#P2148. [SDOI2009] E&D
[SDOI2009] E&D
Description
E and W play a game called E&D.
The rules are as follows: There are piles of stones on the table, numbered . For convenience, we regard pile and pile () as one group. The number of stones in pile is a positive integer .
One split operation is defined as follows: choose any pile of stones and remove it from the table. Then split the other pile in the same group, take some stones from it, and place them at the removed position to form a new pile. After the operation, the number of stones in every pile must be greater than . Obviously, the pile being split must contain at least stones. The two players alternate performing split operations. If, on a player's turn, all piles have exactly stone, then no move is possible and that player loses.
E makes the first move. He wants to know whether there exists a strategy that guarantees he can defeat W. Therefore, he asks F (you) to tell him whether a winning strategy exists. For example, suppose initially there are piles with sizes . E can choose to remove pile , then split pile (he can only split off stone). Next, W can only remove pile , then split pile into and . Finally, it is E's turn; he can only remove the pile of size among the last two piles, and split the other into and . Thus, when it is W's turn, all piles have size , so he loses. Therefore, E has a winning strategy.
Input Format
There are multiple test cases in this problem.
The first line contains an integer , the number of test cases.
For each test case:
The first line contains an integer , the total number of piles on the table; here is the from the problem description.
The second line contains integers .
Output Format
For each test case, if E has a winning strategy, output a single string YES; otherwise, output a single string NO.
2
4
1 2 3 1
6
1 1 1 1 1 1
YES
NO
Hint
For of the testdata, .
For another of the testdata, , .
For of the testdata, , and is even, .
Translated by ChatGPT 5
京公网安备 11011102002149号