310142: CF1788C. Matching Numbers

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Matching Numbers

题意翻译

给定 $m$,如果将 $1,2\dots 2m$ 两两配对,显然会形成 $m$ 对数。定义一对数的价值是两个数之和,希望构造一种方案使得这 $m$ 对数的价值形成一个长度为 $m$,并且公差为 $1$ 的等差数列。

题目描述

You are given an integer $ n $ . Pair the integers $ 1 $ to $ 2n $ (i.e. each integer should be in exactly one pair) so that each sum of matched pairs is consecutive and distinct. Formally, let $ (a_i, b_i) $ be the pairs that you matched. $ \{a_1, b_1, a_2, b_2, \ldots, a_n, b_n\} $ should be a permutation of $ \{1, 2, \ldots, 2n\} $ . Let the sorted list of $ \{a_1+b_1, a_2+b_2, \ldots, a_n+b_n\} $ be $ s_1 < s_2 < \ldots < s_n $ . We must have $ s_{i+1}-s_i = 1 $ for $ 1 \le i \le n - 1 $ .

输入输出格式

输入格式


Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 500 $ ). The description of the test cases follows. For each test case, a single integer $ n $ ( $ 1 \leq n \leq 10^5 $ ) is given. It is guaranteed that the sum of $ n $ over all test cases doesn't exceed $ 10^5 $ .

输出格式


For each test case, if it is impossible to make such a pairing, print "No". Otherwise, print "Yes" followed by $ n $ lines. At each line, print two integers that are paired. You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses. If there are multiple solutions, print any.

输入输出样例

输入样例 #1

4
1
2
3
4

输出样例 #1

Yes
1 2
No
Yes
1 6
3 5
4 2
No

说明

For the third test case, each integer from $ 1 $ to $ 6 $ appears once. The sums of matched pairs are $ 4+2=6 $ , $ 1+6=7 $ , and $ 3+5=8 $ , which are consecutive and distinct.

Input

题意翻译

给定 $m$,如果将 $1,2\dots 2m$ 两两配对,显然会形成 $m$ 对数。定义一对数的价值是两个数之和,希望构造一种方案使得这 $m$ 对数的价值形成一个长度为 $m$,并且公差为 $1$ 的等差数列。

Output

**题目大意:**
给定一个整数 $ m $,需要将整数 $ 1 $ 到 $ 2m $ 两两配对,使得每对数的和能够形成一个长度为 $ m $ 且公差为 $ 1 $ 的等差数列。

**输入格式:**
输入包含多个测试用例。第一行是一个整数 $ t $($ 1 \le t \le 500 $),表示测试用例的数量。接下来 $ t $ 行,每行包含一个整数 $ n $($ 1 \leq n \leq 10^5 $),表示每个测试用例中需要配对的整数范围是 $ 1 $ 到 $ 2n $。

**输出格式:**
对于每个测试用例,如果无法完成所需配对,则输出 "No"。如果能完成配对,则先输出 "Yes",然后输出 $ n $ 行,每行两个整数,表示一对配对的数。如果有多个解决方案,输出任意一个即可。**题目大意:** 给定一个整数 $ m $,需要将整数 $ 1 $ 到 $ 2m $ 两两配对,使得每对数的和能够形成一个长度为 $ m $ 且公差为 $ 1 $ 的等差数列。 **输入格式:** 输入包含多个测试用例。第一行是一个整数 $ t $($ 1 \le t \le 500 $),表示测试用例的数量。接下来 $ t $ 行,每行包含一个整数 $ n $($ 1 \leq n \leq 10^5 $),表示每个测试用例中需要配对的整数范围是 $ 1 $ 到 $ 2n $。 **输出格式:** 对于每个测试用例,如果无法完成所需配对,则输出 "No"。如果能完成配对,则先输出 "Yes",然后输出 $ n $ 行,每行两个整数,表示一对配对的数。如果有多个解决方案,输出任意一个即可。

加入题单

算法标签: