#K5511. Count Unique Pairs
Count Unique Pairs
Count Unique Pairs
You are given several test cases. In each test case, an integer K is provided which represents the number of different ribbon colors. In addition, a sequence of K integers (which may include duplicates) is given; however, the sequence is only for input consistency. Your task is to calculate the number of unique pairs that can be formed from these K colors.
The answer for each test case is determined by the formula:
$$ \frac{K \times (K-1)}{2} $$
For example, if K = 4 then the number of unique pairs is 4*(4-1)/2 = 6.
inputFormat
The input begins with a single integer T, the number of test cases. For each test case, the input consists of two lines:
- The first line contains an integer K representing the number of different ribbon colors.
- The second line contains K space-separated integers representing the ribbon colors. (The list may contain duplicates, but only the value of K is used for the computation.)
outputFormat
For each test case, output one line containing the number of unique pairs that can be formed from the K colors.
## sample2
4
1 2 3 4
5
1 1 2 3 4
6
10
</p>