Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Just Solve It

By Bishal_G · Limits 2s, 512 MB

You are given an array AA of length NN consisting of integer numbers. Your task is to determine the value returned by following “Solve()” function.

var Solve(var N,var A[]) {
  var count=0;
  for(var i=1; i<=N; i++) {
    for(var j=i+1; j<=N; j++) {
      var product=A[i]*A[j];
      if( LSD(product) == 0 ) {
        count++;
      }
    }
  }
  return count;
}

Here, Least Significant Digit (LSD) refers to the digit which occurs rightmost in its decimal representation.

Input

Input starts with an integer TT (1T201 \le T \le 20), denoting the number of test cases. Each case contains an integer NN (1N1000001 ≤ N ≤ 100000) denoting the number of elements of array AA. The next line will contain NN nonnegative integers not greater than 101210^{12} separated by a space, denoting the elements of the array.

Output

For each case of input, output the result of above function as described in the problem statement.

Sample

InputOutput
1
4
1 2 3 5
1

Discussion

Statistics


64% Solution Ratio

showmic96Earliest, Apr '18

md_jakariyaFastest, 0.1s

nasibsuLightest, 131 kB

ArobindoShortest, 362B

Submit

Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.