|
I I U P C 2 0 0 6 |
|
|
Problem D: Divisibility Testing |
|
|
Input: standard input |
|
|
|
|
|
You will be given a list of n integers, <a1 a2 a3 . . . an> and an integer k. Find out the number of ways of choosing 2 integers (ai, aj), such that ai ≤ aj and 1 ≤ i, j ≤ n and i ≠ j and (ai + aj) is divisible by k. Every pair must be distinct. Two pairs, (a, b) and (c, d), are equal if a is equal to c and b is equal to d. Suppose we are given 5 integers <4 1 2 2 3> and k = 1. There are 7 ways of choosing different pairs that meets the above restrictions. (1, 2) (1, 3) (1, 4) (2, 2) (2, 3) (2, 4) (3, 4). |
|
|
Input |
|
|
The first line of input contains an integer T that determines the number of test cases. Each test case contains two lines. The first line consists of two integers n and k. The next line contains n integers. The i-th integer gives the value of ai. |
|
|
Output |
|
|
For each test case, output the case number followed by the number of ways to choose the pairs. |
|
|
Constraints |
|
|
- T < 100 |
|
|
Sample
Input |
Output
for Sample Input |
|
2 |
Case 1: 7 |
|
|
|
|
Problemsetter: Sohel Hafiz |
|