Find pair

4.5

2 votes
Easy
Problem

You are given an array(of distinct integers) and an another integer SUM. You need to report the number of pairs which add up to that particular SUM.

The first line of input would contain Q(number of test cases)and the following 3*Q lines would containe n(number of elements in an array), the elements of the array (separated by space) and the SUM on separate lines.

INPUT

2
5
1 2 3 4 5
5
4
1 2 3 5
3

Your output must consist of Q lines with the answer on each line.

OUTPUT

2
1
Constraints
Q <= 1000
n <= 100 
0 < Integers in array <= 100
SUM <= 200

Sample Input
2
5
1 2 3 4 5
5
4
1 2 3 5
3
Sample Output
2
1
Time Limit: 2
Memory Limit: 256
Source Limit:
Contributers:
Editor Image

?