#P10565. [ICPC2024 Xi'an I] Chained Lights

[ICPC2024 Xi'an I] Chained Lights

题目描述

You have nn lights in a row. Initially, they are all off.

You are going to press these nn lights one by one. When you press light ii, light ii 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 jj satisfied ij,i<jni|j,i< j\le n, press light jj once.

For example, if n=4n=4, when you press light 11, light 11 will turn on, and then you will press light 2,3,42,3,4. Since you pressed light 22, light 22 will turn on and you will press light 44, which will cause light 4 to turn on. After all the operations, lights 1,2,31,2,3 will be turned on and light 44 is still off.

You will press these nn lights and do the operations as mentioned above one by one. After all the operations, you want to know whether light kk 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 T(1T105)T(1\le T\le10^5), which represents the number of testcases.

Each of the testcases contains two integers n,k(1kn106)n,k(1\le k\le n\le10^6) in a single line.

输出格式

For each testcase, if light kk is turned on in the end, output YES\text{YES}, otherwise output NO\text{NO}.

2
1 1
3 2
YES
NO