[ICPC2022 Jinan R] Identical Parity
题意翻译
### 题目描述
定义一个序列的 **权值** 等于这个序列所有的元素之和。
试判断:是否存在一个长度为 $n$ 的 **排列**,满足以下约束条件?
- 其所有长度为 $k$ 的 **子区间** 的权值具有相同的奇偶性。
### 输入格式
第一行一个整数 $T$ $(1\leqslant T\leqslant 10^5)$,表示测试数据组数。
对于每组测试数据,仅有一行两个整数 $n,k$ $(1\leqslant k\leqslant n\leqslant 10^9)$,含义见“题目描述”。
### 输出格式
对于每组测试数据,输出一行一个字符串。若存在符合题意的排列,输出 $\texttt{Yes}$;否则,输出 $\texttt{No}$。
你可以以任意的大小写输出 $\texttt{Yes}$ 和 $\texttt{No}$(例如,$\texttt{YES}$,$\texttt{yEs}$ 和 $\texttt{yes}$ 都会被视作合法的输出)。
### 样例解释
对于第一组测试数据,能够证明不存在任何符合题意的排列。
对于第二组测试数据,$[1,2,3,4]$ 是一个符合题意的排列。其所有长度为 $2$ 的子区间分别为 $[1,2],[2,3],[3,4]$,它们的权值分别为 $3,5,7$,具有相同的奇偶性。
对于第三组测试数据,$[1,2,3,5,4]$ 是一个符合题意的排列。其所有长度为 $3$ 的子区间分别为 $[1,2,3],[2,3,5],[3,5,4]$,它们的权值分别为 $6,10,12$,具有相同的奇偶性。
题目描述
Let the value of a sequence be the sum of all numbers in it.
Determine whether there exists a permutation of length $n$ such that the values of all subsegments of length $k$ 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 $n$ is a sequence in which each integer from $1$ to $n$ appears exactly once.
输入输出格式
输入格式
The first line contains one integer $T~(1\le T \le 10^5)$, the number of test cases.
For each test case, the only line contains two integers $n,k~(1 \le k \le n \le 10^9)$.
输出格式
For each test case, output $\texttt{Yes}$ (without quotes) if there exists a valid permutation, or $\texttt{No}$ (without quotes) otherwise.
You can output $\texttt{Yes}$ and $\texttt{No}$ in any case (for example, strings $\texttt{YES}$, $\texttt{yEs}$ and $\texttt{yes}$ will be recognized as positive responses).
输入输出样例
输入样例 #1
3
3 1
4 2
5 3
输出样例 #1
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]$ is one of the valid permutations. Its subsegments of length $2$ are $[1,2],[2,3],[3,4]$. Their values are $3,5,7$, respectively. They share the same parity.
In the third test case, $[1,2,3,5,4]$ is one of the valid permutations. Its subsegments of length $3$ are $[1,2,3],[2,3,5],[3,5,4]$. Their values are $6,10,12$, respectively. They share the same parity.