CF1933D.Turtle Tenacity: Continual Mods

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Given an array a1,a2,…,ana_1, a_2, \ldots, a_n, determine whether it is possible to rearrange its elements into b1,b2,…,bnb_1, b_2, \ldots, b_n, such that b1 mod b2 mod … mod bn≠0b_1 \bmod b_2 \bmod \ldots \bmod b_n \neq 0.

Here x mod yx \bmod y denotes the remainder from dividing xx by yy. Also, the modulo operations are calculated from left to right. That is, x mod y mod z=(x mod y) mod zx \bmod y \bmod z = (x \bmod y) \bmod z. For example, 2024 mod 1000 mod 8=(2024 mod 1000) mod 8=24 mod 8=02024 \bmod 1000 \bmod 8 = (2024 \bmod 1000) \bmod 8 = 24 \bmod 8 = 0.

给定一个数组 a1,a2,…,ana_1, a_2, \ldots, a_n,判断是否可以将其元素重新排列为 b1,b2,…,bnb_1, b_2, \ldots, b_n,使得 b1 mod b2 mod … mod bn≠0b_1 \bmod b_2 \bmod \ldots \bmod b_n \neq 0。

其中,x mod yx \bmod y 表示 xx 除以 yy 所得的余数;且模运算按从左到右的顺序进行,即 x mod y mod z=(x mod y) mod zx \bmod y \bmod z = (x \bmod y) \bmod z。例如,2024 mod 1000 mod 8=(2024 mod 1000) mod 8=24 mod 8=02024 \bmod 1000 \bmod 8 = (2024 \bmod 1000) \bmod 8 = 24 \bmod 8 = 0。

输入格式

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

The first line of each test case contains a single integer nn (2≤n≤1052 \le n \le 10^5).

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

The sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

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

每个测试用例的第一行包含一个整数 nn(2≤n≤1052 \le n \le 10^5)。

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

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

输出格式

For each test case, output "YES" if it is possible, "NO" otherwise.

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.

对于每个测试用例,如果可能则输出 “YES”,否则输出 “NO”。

您可以以任意大小写形式输出答案(大写或小写)。例如,字符串 “yEs”、“yes”、“Yes” 和 “YES” 均会被识别为肯定回答。

输入输出样例

  • 输入#1

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

    输出#1

    YES
    NO
    YES
    NO
    YES
    NO
    YES
    NO

说明/提示

In the first test case, rearranging the array into b=[1,2,3,4,5,6]b = [1, 2, 3, 4, 5, 6] (doing nothing) would result in 1 mod 2 mod 3 mod 4 mod 5 mod 6=11 \bmod 2 \bmod 3 \bmod 4 \bmod 5 \bmod 6 = 1. Hence it is possible to achieve the goal.

In the second test case, the array bb must be equal to [3,3,3,3,3][3, 3, 3, 3, 3], which would result in 3 mod 3 mod 3 mod 3 mod 3=03 \bmod 3 \bmod 3 \bmod 3 \bmod 3 = 0. Hence it is impossible to achieve the goal.

In the third test case, rearranging the array into b=[3,2,2]b = [3, 2, 2] would result in 3 mod 2 mod 2=13 \bmod 2 \bmod 2 = 1. Hence it is possible to achieve the goal.

在第一个测试用例中,将数组重排为 b=[1,2,3,4,5,6]b = [1, 2, 3, 4, 5, 6](即不作任何操作)会得到 1 mod 2 mod 3 mod 4 mod 5 mod 6=11 \bmod 2 \bmod 3 \bmod 4 \bmod 5 \bmod 6 = 1。因此可以达成目标。

在第二个测试用例中,数组 bb 必须等于 [3,3,3,3,3][3, 3, 3, 3, 3],此时计算结果为 3 mod 3 mod 3 mod 3 mod 3=03 \bmod 3 \bmod 3 \bmod 3 \bmod 3 = 0。因此无法达成目标。

在第三个测试用例中,将数组重排为 b=[3,2,2]b = [3, 2, 2] 会得到 3 mod 2 mod 2=13 \bmod 2 \bmod 2 = 1。因此可以达成目标。

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

首页