CF1788C.Matching Numbers

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an integer nn . Pair the integers 11 to 2n2n (i.e. each integer should be in exactly one pair) so that each sum of matched pairs is consecutive and distinct.

Formally, let (ai,bi)(a_i, b_i) be the pairs that you matched. {a1,b1,a2,b2,,an,bn}\{a_1, b_1, a_2, b_2, \ldots, a_n, b_n\} should be a permutation of {1,2,,2n}\{1, 2, \ldots, 2n\} . Let the sorted list of {a1+b1,a2+b2,,an+bn}\{a_1+b_1, a_2+b_2, \ldots, a_n+b_n\} be s1<s2<<sns_1 < s_2 < \ldots < s_n . We must have si+1si=1s_{i+1}-s_i = 1 for 1in11 \le i \le n - 1 .

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t5001 \le t \le 500 ). The description of the test cases follows.

For each test case, a single integer nn ( 1n1051 \leq n \leq 10^5 ) is given.

It is guaranteed that the sum of nn over all test cases doesn't exceed 10510^5 .

输出格式

For each test case, if it is impossible to make such a pairing, print "No".

Otherwise, print "Yes" followed by nn 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 11 to 66 appears once. The sums of matched pairs are 4+2=64+2=6 , 1+6=71+6=7 , and 3+5=83+5=8 , which are consecutive and distinct.

首页