GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Tuesday 2 August 2022

[Solution] Add Modulo 10 Codeforces Solution


E. Add Modulo 10
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given an array of n integers a1,a2,,an

You can apply the following operation an arbitrary number of times:

  • select an index i (1in) and replace the value of the element ai with the value ai+(aimod10), where aimod10 is the remainder of the integer dividing ai by 10.

For a single index (value i), this operation can be applied multiple times. If the operation is applied repeatedly to the same index, then the current value of ai is taken into account each time. For example, if ai=47 then after the first operation we get ai=47+7=54, and after the second operation we get ai=54+4=58.

Check if it is possible to make 

Solution Click Below:-  👉CLICK HERE👈

👇👇👇👇👇

 occupied

all array elements equal by applying multiple (possibly zero) operations.

For example, you have an array [6,11].

  • Let's apply this operation to the first element of the array. Let's replace a1=6 with a1+(a1mod10)=6+(6mod10)=6+6=12. We get the array [12,11].
  • Then apply this operation to the second element of the array. Let's replace a2=11 with a2+(a2mod10)=11+(11mod10)=11+1=12. We get the array [12,12].

Thus, by applying 2 operations, you can make all elements of an array equal.

Input

The first line contains one integer t (1t104) — the number of test cases. What follows is a description of each test case.

The first line of each test case contains one integer n (1n2105) — the size of the array.

The second line of each test case contains n integers ai (0ai109) — array elements.

It is guaranteed that the sum of n over all test cases does not exceed 2105.

Output

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 yEsyesYes and YES will be recognized as a positive answer) .

No comments:

Post a Comment