P3179 [HAOI2015] Array Game
Description
There is an array of length $n$. Two players, A and B, play the following game on it: initially, some cells in the array are white and some are black. The players take turns.
On each turn, the current player chooses a white cell with index $x$. Then they choose an integer $k$ between $1 \ldots \lfloor \dfrac{n}{x} \rfloor$, and flip the colors of all cells with indices $x, 2\times x, \ldots, k\times x$. The player who cannot make a move loses.
Now A (the first player) has several queries. For each query, you are given an initial state of the array. You need to determine whether A has a winning strategy for that initial state.
Input Format
The first line contains an integer $n$, the length of the array.
The second line contains an integer $k$, the number of queries.
The next $2\times k$ lines describe the queries, two lines per query.
In these two lines, the first line contains a positive integer $w$, the number of white cells in the array. The second line contains $w$ integers between $1$ and $n$, inclusive, which are the indices of the white cells.
Output Format
For each query, output one line with a string: output `Yes` if the first player has a winning strategy, otherwise output `No`.
Explanation/Hint
#### Explanation for Sample Input/Output 1
In the first query, A chooses index $1$ and flips cells $1\times 1$ and $2\times 1$.
In the second query, no matter which index A chooses, they can flip only one cell. B can then flip the other cell.
#### Constraints
For $30\%$ of the testdata, $n \leq 20$.
For $50\%$ of the testdata, $n \leq 10^6$.
For $70\%$ of the testdata, $n \leq 10^7$.
For $100\%$ of the testdata, $n \leq 10^9$, $k, w \leq 100$, and no cell appears more than once within a single query.
Translated by ChatGPT 5