spoj#REAYZCODETST. Coding Test
Coding Test
Great programmer “Tourist” is attending a coding test. In this test he is asked to solve an easy problem. The problem description is,
There is an array a consists of n integers and another nonnegative integer x. He need to find the number of pair (i, j) where i!=j & ai – aj = x.
As it is very easy for him, he gave you this problem and start trying another hard problem. Can you solve this for him?
Input
Input starts with an integer t (1 ≤ t ≤ 10), number of test case.
Each case contains two integer n (1 ≤ n ≤ 105), and x (0 ≤ x ≤ 109).
Next line contains n separated integers ai (1 ≤ ai ≤ 109).
Output
For each case, print the case number and the number of pairs which meet the above condition.
Example
Input:2
5 3
5 1 4 2 3
10 2
12 17 19 13 17 11 17 12 15 14Output:
Case 1: 2
Case 2: 10