#P9671. [ICPC 2022 Jinan R] Identical Parity

    ID: 9027 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 3 Uploaded By: Tags>2022Special JudgeO2优化ICPC济南

[ICPC 2022 Jinan R] Identical Parity

题目描述

Let the value of a sequence be the sum of all numbers in it.

Determine whether there exists a permutation of length nn such that the values of all subsegments of length kk of the permutation share the same parity. The values share the same parity means that they are all odd numbers or they are all even numbers.

A subsegment of a permutation is a contiguous subsequence of that permutation. A permutation of length nn is a sequence in which each integer from 11 to nn appears exactly once.

输入格式

The first line contains one integer T (1T105)T~(1\le T \le 10^5), the number of test cases.

For each test case, the only line contains two integers n,k (1kn109)n,k~(1 \le k \le n \le 10^9).

输出格式

For each test case, output Yes\texttt{Yes} (without quotes) if there exists a valid permutation, or No\texttt{No} (without quotes) otherwise.

You can output Yes\texttt{Yes} and No\texttt{No} in any case (for example, strings YES\texttt{YES}, yEs\texttt{yEs} and yes\texttt{yes} will be recognized as positive responses).

3
3 1
4 2
5 3
No
Yes
Yes

提示

In the first test case, it can be shown that there does not exist any valid permutation.

In the second test case, [1,2,3,4][1,2,3,4] is one of the valid permutations. Its subsegments of length 22 are [1,2],[2,3],[3,4][1,2],[2,3],[3,4]. Their values are 3,5,73,5,7, respectively. They share the same parity.

In the third test case, [1,2,3,5,4][1,2,3,5,4] is one of the valid permutations. Its subsegments of length 33 are [1,2,3],[2,3,5],[3,5,4][1,2,3],[2,3,5],[3,5,4]. Their values are 6,10,126,10,12, respectively. They share the same parity.