CF2226C.Mental Monumental (Easy Version)

普及/提高-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This is the easy version of this problem. The difference between the versions is that in this version, you are required to find only the value of f(a)f(a).

For any array [c1,c2,…,cm][c_1, c_2, \ldots, c_m], we define f(c)f(c) as the maximum possible mex⁡(c)\operatorname{mex}(c)∗^{\text{∗}} that can be achieved by performing the following operation exactly once:

  • Choose an integer array [b1,b2,…,bm][b_1, b_2, \ldots, b_m] such that bi≥1b_i \ge 1 for all 1≤i≤m1 \le i \le m;
  • Set ci:=ci  mod  bic_i := c_i \, \bmod \, b_i†^{\text{†}} for every 1≤i≤m1 \le i \le m.

You are given an array aa consisting of nn non-negative integers. Determine the value of f(a)f(a).

∗^{\text{∗}}mex⁡(c)\operatorname{mex}(c) denotes the minimum excluded (MEX) of the integers in cc. For example, mex⁡([2,2,1])=0\operatorname{mex}([2,2,1])=0 because 00 does not belong to the array, and mex⁡([0,3,1,2])=4\operatorname{mex}([0,3,1,2])=4 because 00, 11, 22, and 33 appear in the array, but 44 does not.

†^{\text{†}}u mod vu \bmod v denotes the remainder from dividing uu by vv.

这是本题的简单版本。两个版本的区别在于:在本版本中,你只需计算出 f(a)f(a) 的值。

对于任意数组 [c1,c2,…,cm][c_1, c_2, \ldots, c_m],我们定义 f(c)f(c) 为:在恰好执行一次如下操作的前提下,所能达到的最大可能的 mex⁡(c)\operatorname{mex}(c)∗^{\text{∗}} 值:

  • 选择一个整数数组 [b1,b2,…,bm][b_1, b_2, \ldots, b_m],满足对所有 1≤i≤m1 \le i \le m 都有 bi≥1b_i \ge 1;
  • 对每个 1≤i≤m1 \le i \le m,令 ci:=ci  mod  bic_i := c_i \, \bmod \, b_i†^{\text{†}}。

给定一个由 nn 个非负整数组成的数组 aa,请确定 f(a)f(a) 的值。

∗^{\text{∗}}mex⁡(c)\operatorname{mex}(c) 表示数组 cc 中整数的最小未出现值(MEX)。例如,mex⁡([2,2,1])=0\operatorname{mex}([2,2,1])=0,因为 00 不在数组中;而 mex⁡([0,3,1,2])=4\operatorname{mex}([0,3,1,2])=4,因为 00、11、22、33 均出现在数组中,但 44 没有出现。

†^{\text{†}}u mod vu \bmod v 表示 uu 除以 vv 所得的余数。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The first line of each testcase contains a single integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the length of the array aa.

The second line of each testcase contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai≤1060 \le a_i \le 10^6) — the elements of the array aa.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5. It is guaranteed that the sum of max⁡(a1,a2,…,an)\max(a_1,a_2,\ldots,a_n) over all test cases does not exceed 10610^6.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)—— 数组 aa 的长度。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai≤1060 \le a_i \le 10^6)—— 数组 aa 的元素。

保证所有测试用例的 nn 之和不超过 2⋅1052 \cdot 10^5。保证所有测试用例的 max⁡(a1,a2,…,an)\max(a_1,a_2,\ldots,a_n) 之和不超过 10610^6。

输出格式

For each testcase, output a single integer — the value of f(a)f(a).

对于每个测试用例,输出一个整数——即 f(a)f(a) 的值。

输入输出样例

  • 输入#1

    4
    4
    0 1 2 3
    2
    6 7
    6
    8 1 7 6 4 3
    9
    9 9 8 2 4 4 3 5 3

    输出#1

    4
    2
    5
    6

说明/提示

For the first testcase, choosing b=[1,2,3,4]b = [1, 2, 3, 4] leaves aa unchanged and we have mex⁡(a)=4\operatorname{mex}(a) = 4.

For the second testcase, choosing b=[3,3]b = [3, 3] makes a=[0,1]a = [0, 1]. Thus, we have mex⁡(a)=2\operatorname{mex}(a) = 2.

对于第一个测试用例,选择 b=[1,2,3,4]b = [1, 2, 3, 4] 使得 aa 保持不变,此时有 mex⁡(a)=4\operatorname{mex}(a) = 4。

对于第二个测试用例,选择 b=[3,3]b = [3, 3] 使得 a=[0,1]a = [0, 1]。因此,此时有 mex⁡(a)=2\operatorname{mex}(a) = 2。

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

首页