#K81682. Distinct Integer Concatenations
Distinct Integer Concatenations
Distinct Integer Concatenations
You are given an array of integers for each test case. Your task is to count the number of distinct integers formed by concatenating any two different integers from the array. The concatenation of two integers a and b is defined as the integer represented by the string formed when a and b are written one after the other. For example, concatenating 12 and 34 results in 1234.
Formally, given an array \(A = [a_1, a_2, \dots, a_n]\), you need to count the number of distinct integers of the form \(\text{int}(a_i \Vert a_j)\) where \(i \neq j\) and \(\Vert\) denotes concatenation.
Note that the resulting integer can be very large, but you only need to count the distinct numbers.
inputFormat
The input is read from standard input (stdin). The first line contains an integer \(T\) representing the number of test cases. Each test case consists of two lines:
- The first line contains an integer \(n\), the number of integers in the array.
- The second line contains \(n\) space-separated integers.
It is guaranteed that \(0 \leq n \leq 10^5\) overall (with per test case constraints ensuring that a brute force approach is acceptable for the given input sizes).
outputFormat
For each test case, output a single integer in a new line indicating the count of distinct concatenated integers that can be formed by concatenating any two different integers from the array.
## sample2
3
1 2 3
2
1 1
6
1
</p>