CF2259B.Minus Two

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given an array a1,a2,…,ana_1, a_2, \ldots, a_n. You may perform the following operation:

  • For all indices ii (1≤i≤n1 \leq i \leq n), set ai=∣ai−2∣a_i = |a_i - 2|.

Find the maximum possible frequency of any integer in aa after performing the operation an arbitrary number (possibly zero) of times.

给你一个数组 a1,a2,…,ana_1, a_2, \ldots, a_n。你可以执行以下操作:

  • 对所有下标 ii(1≤i≤n1 \leq i \leq n),令 ai=∣ai−2∣a_i = |a_i - 2|。

求在执行任意次(可能为零次)该操作后,数组 aa 中任意整数所能达到的最大出现频数。

输入格式

The first line of each input contains an integer tt (1≤t≤1041 \leq t \leq 10^4) — the number of test cases.

The first line of each test case contains an integer nn (1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5) — the length of aa.

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \leq a_i \leq 10^9) — the array aa.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

每组输入的第一行包含一个整数 tt(1≤t≤1041 \leq t \leq 10^4)—— 测试用例的数量。

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

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \leq a_i \leq 10^9)—— 数组 aa。

保证所有测试用例的 nn 之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, output a single integer denoting the maximum possible frequency of any integer in aa after performing the operation an arbitrary number of times.

对于每个测试用例,输出一个整数,表示在执行该操作任意次数后,数组 aa 中任意整数所能达到的最大可能频率。

输入输出样例

  • 输入#1

    5
    2
    1 3
    4
    1 1 1 2
    3
    6 7 8
    4
    2 2 2 2
    5
    1 10 100 1000 100000

    输出#1

    2
    3
    1
    4
    3

说明/提示

In the first test case, we can perform the operation once to have a=[∣1−2∣,∣3−2∣]=[1,1]a = [|1 - 2|, |3 - 2|] = [1, 1], which means the maximum possible frequency of any integer in aa is 22.

In the second test case, the maximum frequency of an integer in aa is 33. It can be shown that, no matter how many operations we perform, the maximum possible frequency of an integer in aa will never exceed 33.

在第一个测试用例中,我们可以执行一次操作,得到 a=[∣1−2∣,∣3−2∣]=[1,1]a = [|1 - 2|, |3 - 2|] = [1, 1],这意味着 aa 中任意整数的最大可能频数为 22。

在第二个测试用例中,aa 中某个整数的最大频数为 33。可以证明,无论我们执行多少次操作,aa 中任意整数的最大可能频数均不会超过 33。

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

首页