CF856A.Set Theory

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Masha and Grisha like studying sets of positive integers.

One day Grisha has written a set A containing n different integers a__i on a blackboard. Now he asks Masha to create a set B containing n different integers b__j such that all _n_2 integers that can be obtained by summing up a__i and b__j for all possible pairs of i and j are different.

Both Masha and Grisha don't like big numbers, so all numbers in A are from 1 to 106, and all numbers in B must also be in the same range.

Help Masha to create the set B that satisfies Grisha's requirement.

玛莎和格里沙喜欢研究正整数集合。

一天,格里沙在黑板上写下一个包含 nn 个互不相同的整数 aia_i 的集合 AA。现在他请玛莎构造一个包含 nn 个互不相同的整数 bjb_j 的集合 BB,使得对所有可能的下标对 (i,j)(i,j),将 aia_i 与 bjb_j 相加所得的全部 n2n^2 个整数互不相同。

玛莎和格里沙都不喜欢过大的数,因此集合 AA 中的所有数均在 11 到 10610^6 之间,且集合 BB 中的所有数也必须落在同一范围内。

请帮助玛莎构造出满足格里沙要求的集合 BB。

输入格式

Input data contains multiple test cases. The first line contains an integer t — the number of test cases (1 ≤ t ≤ 100).

Each test case is described in the following way: the first line of the description contains one integer n — the number of elements in A (1 ≤ n ≤ 100).

The second line contains n integers a__i — the elements of A (1 ≤ a__i ≤ 106).

输入数据包含多个测试用例。第一行包含一个整数 tt —— 测试用例的数量(1 ≤ t ≤ 1001 \le t \le 100)。

每个测试用例按如下方式描述:描述的第一行包含一个整数 nn —— 数组 AA 中的元素个数(1 ≤ n ≤ 1001 \le n \le 100)。

第二行包含 nn 个整数 aia_i —— 数组 AA 的元素(1 ≤ ai ≤ 1061 \le a_i \le 10^6)。

输出格式

For each test first print the answer:

  • NO, if Masha's task is impossible to solve, there is no way to create the required set B.
  • YES, if there is the way to create the required set. In this case the second line must contain n different positive integers b__j — elements of B (1 ≤ b__j ≤ 106). If there are several possible sets, output any of them.

对于每组测试数据,首先输出答案:

  • 若玛莎的任务无法完成,即不存在满足要求的集合 BB,则输出 NO;
  • 若存在满足要求的集合,则输出 YES。此时第二行需包含 nn 个互不相同的正整数 bjb_j —— 即集合 BB 的元素(1 ≤ bj ≤ 1061 \leq b_j \leq 10^6)。若存在多种可能的集合,输出任意一种即可。

输入输出样例

  • 输入#1

    3
    3
    1 10 100
    1
    1
    2
    2 4

    输出#1

    YES
    1 2 3 
    YES
    1 
    YES
    1 2

输入解题思路,AI测评打分。不知道怎么写?

首页