CF1686A.Everything Everywhere All But One
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array of n integers a1,a2,…,an . After you watched the amazing film "Everything Everywhere All At Once", you came up with the following operation.
In one operation, you choose n−1 elements of the array and replace each of them with their arithmetic mean (which doesn't have to be an integer). For example, from the array [1,2,3,1] we can get the array [2,2,2,1] , if we choose the first three elements, or we can get the array [34,34,3,34] , if we choose all elements except the third.
Is it possible to make all elements of the array equal by performing a finite number of such operations?
输入格式
The first line of the input contains a single integer t ( 1≤t≤200 ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer n ( 3≤n≤50 ) — the number of integers.
The second line of each test case contains n integers a1,a2,…,an ( 0≤ai≤100 ).
输出格式
For each test case, if it is possible to make all elements equal after some number of operations, output YES . Otherwise, output NO .
You can output YES and NO in any case (for example, strings yEs , yes , Yes will be recognized as a positive response).
输入输出样例
输入#1
4 3 42 42 42 5 1 2 3 4 5 4 4 3 2 1 3 24 2 22
输出#1
YES YES NO NO
说明/提示
In the first test case, all elements are already equal.
In the second test case, you can choose all elements except the third, their average is 41+2+4+5=3 , so the array will become [3,3,3,3,3] .
It's possible to show that it's impossible to make all elements equal in the third and fourth test cases.