A Simple If-Else and Loop Problem. Or, Is It? 😕

Limits 3s, 1.0 GB

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

Input will start with an integer, T (≤ 100) denoting the number of test cases.
Each case will contain three lines:

  1. An integer, N (1 ≤ N ≤ 105)
  2. Two space separated integers, A B (1 ≤ A ≤ B ≤ 106)
  3. N space separated integers, each of which is called Pi (1 ≤ Pi ≤ 104)

Output

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.

Sample

InputOutput
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

Submit

Login to submit.

Statistics

49% Solution Ratio
IamHotEarliest, Jan '18
white_monsterFastest, 0.1s
IamHotLightest, 524 kB
ex_nihiloShortest, 323B
Toph uses cookies. By continuing you agree to our Cookie Policy.