#C14549. Find Pair With Target Sum
Find Pair With Target Sum
Find Pair With Target Sum
Given a list of integers \(a_1, a_2, \dots, a_n\) and a target value \(T\), determine whether there exist two numbers in the list such that their sum equals \(T\). If such a pair exists, output the pair (in the order the pair is discovered according to the algorithm); otherwise, output None
. The pair should consist of two integers, and note that pairs consisting of the same number (if it appears at least twice) are allowed.
Example: For the list [10, 15, 3, 7] and \(T = 17\), the output should be 10 7
because \(10 + 7 = 17\>.
inputFormat
The input is read from standard input (stdin) and has the following format:
- An integer \(n\) representing the number of elements in the list.
- A line of \(n\) space-separated integers representing the list.
- An integer representing the target sum \(T\).
If \(n = 0\), the second line will be empty.
outputFormat
Print the output to standard output (stdout). If a valid pair exists, output the two integers separated by a space. If no such pair exists, output the string None
(case sensitive).
4
10 15 3 7
17
10 7
</p>