#C5878. Pair Sum Problem
Pair Sum Problem
Pair Sum Problem
Given a list of integers and a target integer, determine if there exists a pair of distinct integers in the list whose sum is equal to the target.
More formally, given an array \(A\) and an integer \(T\), check if there exist indices \(i \neq j\) such that \(A[i] + A[j] = T\). This can be expressed in LaTeX as:
$$\exists\, i,j, \; i \neq j \text{ such that } A[i] + A[j] = T.$$
inputFormat
The input is read from standard input (stdin) and consists of three lines:
- An integer \(n\) representing the number of elements in the list.
- A line containing \(n\) space-separated integers representing the list.
- An integer representing the target sum \(T\).
For example:
4 2 7 11 15 9
outputFormat
Output a single line to standard output (stdout) containing either True
if there exists a pair of distinct integers that sum to the target, or False
otherwise.
For the above example, the output would be:
True## sample
4
2 7 11 15
9
True