CF1933D.Turtle Tenacity: Continual Mods
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Given an array a1,a2,…,an, determine whether it is possible to rearrange its elements into b1,b2,…,bn, such that b1modb2mod…modbn=0.
Here xmody denotes the remainder from dividing x by y. Also, the modulo operations are calculated from left to right. That is, xmodymodz=(xmody)modz. For example, 2024mod1000mod8=(2024mod1000)mod8=24mod8=0.
给定一个数组 a1,a2,…,an,判断是否可以将其元素重新排列为 b1,b2,…,bn,使得 b1modb2mod…modbn=0。
其中,xmody 表示 x 除以 y 所得的余数;且模运算按从左到右的顺序进行,即 xmodymodz=(xmody)modz。例如,2024mod1000mod8=(2024mod1000)mod8=24mod8=0。
输入格式
The first line of the input contains a single integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains a single integer n (2≤n≤105).
The second line of each test case contains n integers a1,a2,…,an (1≤ai≤109).
The sum of n over all test cases does not exceed 2⋅105.
输入的第一行包含一个整数 t(1≤t≤104)—— 表示测试用例的数量。
每个测试用例的第一行包含一个整数 n(2≤n≤105)。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109)。
所有测试用例的 n 之和不超过 2⋅105。
输出格式
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] (doing nothing) would result in 1mod2mod3mod4mod5mod6=1. Hence it is possible to achieve the goal.
In the second test case, the array b must be equal to [3,3,3,3,3], which would result in 3mod3mod3mod3mod3=0. Hence it is impossible to achieve the goal.
In the third test case, rearranging the array into b=[3,2,2] would result in 3mod2mod2=1. Hence it is possible to achieve the goal.
在第一个测试用例中,将数组重排为 b=[1,2,3,4,5,6](即不作任何操作)会得到 1mod2mod3mod4mod5mod6=1。因此可以达成目标。
在第二个测试用例中,数组 b 必须等于 [3,3,3,3,3],此时计算结果为 3mod3mod3mod3mod3=0。因此无法达成目标。
在第三个测试用例中,将数组重排为 b=[3,2,2] 会得到 3mod2mod2=1。因此可以达成目标。
输入解题思路,AI测评打分。不知道怎么写?