#K90947. Can Sum to K

    ID: 37865 Type: Default 1000ms 256MiB

Can Sum to K

Can Sum to K

You are given an array of integers and a target integer \( k \). Your task is to determine whether there exist two distinct elements in the array such that their sum equals \( k \), i.e., find if there exist indices \( i \) and \( j \) with \( i \neq j \) such that \( a_i + a_j = k \).

The input consists of multiple test cases. For each test case, you will be given the number of elements, the list of integers, and finally the target value \( k \). For each test case output True if such a pair exists or False if it does not.

Example:

Input:
3
5
1 2 3 4 5
9
5
0 -1 2 -3 1
-2
3
3 7 1
5

Output: True True False

</p>

inputFormat

The first line contains an integer \( T \) representing the number of test cases. Each test case consists of three parts:

  1. A line containing an integer \( n \) denoting the number of elements in the array.
  2. A line with \( n \) space-separated integers representing the array elements.
  3. A line containing an integer \( k \), the target sum.

All input is provided via standard input (stdin).

outputFormat

For each test case, output a single line containing either True if there exists a pair of distinct elements in the array that sum up to \( k \), or False otherwise. The output is printed to standard output (stdout).

## sample
3
5
1 2 3 4 5
9
5
0 -1 2 -3 1
-2
3
3 7 1
5
True

True False

</p>