[Solution] Add Modulo 10 Codeforces Solution
You are given an array of integers
You can apply the following operation an arbitrary number of times:
- select an index () and replace the value of the element with the value , where is the remainder of the integer dividing by .
For a single index (value ), this operation can be applied multiple times. If the operation is applied repeatedly to the same index, then the current value of is taken into account each time. For example, if then after the first operation we get , and after the second operation we get .
Check if it is possible to make
occupied
all array elements equal by applying multiple (possibly zero) operations.
For example, you have an array .
- Let's apply this operation to the first element of the array. Let's replace with . We get the array .
- Then apply this operation to the second element of the array. Let's replace with . We get the array .
Thus, by applying operations, you can make all elements of an array equal.
The first line contains one integer () — the number of test cases. What follows is a description of each test case.
The first line of each test case contains one integer () — the size of the array.
The second line of each test case contains integers () — array elements.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case print:
- YES if it is possible to make all array elements equal;
- NO otherwise.
You can print YES and NO in any case (for example, the strings yEs, yes, Yes and YES will be recognized as a positive answer) .
No comments:
Post a Comment