The requirement for this problem is as simple as it can be.
You will be given a sequence of N integers: P1, P2, … , Pn. You have to find the number of possible pairs (Pi, Pj) such that: i ≠j and A ≤ Pi + Pj ≤ B where A and B are two integers.
Input will start with an integer, T (≤ 100) denoting the number of test cases.
Each case will contain three lines:
For each case, print a single line in this format Case x: z where x is the case number and z is the number of possible ways to form such pair.
Input | Output |
---|---|
2 5 3 6 1 2 3 4 5 11 11 20 16 11 4 14 7 6 16 9 17 16 8 | Case 1: 6 Case 2: 19 |
Explanation of Sample Case 1
The possible pairs are:
1 + 2 = 3
1 + 3 = 4
1 + 4 = 5
1 + 5 = 6
2 + 3 = 5
2 + 4 = 6