luogu#P10565. [ICPC2024 Xi'an I] Chained Lights
[ICPC2024 Xi'an I] Chained Lights
题目描述
You have lights in a row. Initially, they are all off.
You are going to press these lights one by one. When you press light , light will switch its state, which means it will turn on if it's off and turn off if it's on, and then for every satisfied , press light once.
For example, if , when you press light , light will turn on, and then you will press light . Since you pressed light , light will turn on and you will press light , which will cause light 4 to turn on. After all the operations, lights will be turned on and light is still off.
You will press these lights and do the operations as mentioned above one by one. After all the operations, you want to know whether light is on or off.
You can also use the following code to understand the meaning of the problem:
void press(int x)
{
light[x]^=1;
for (int y=x+x;y<=n;y+=x) press(y);
}
for (int i=1;i<=n;i++) press(i);
输入格式
There are multiple testcases.
The first line contains an integer , which represents the number of testcases.
Each of the testcases contains two integers in a single line.
输出格式
For each testcase, if light is turned on in the end, output , otherwise output .
2
1 1
3 2
YES
NO