#K46902. Find Pair with Sum

    ID: 28079 Type: Default 1000ms 256MiB

Find Pair with Sum

Find Pair with Sum

Given a list of integers and a target integer, your task is to determine whether there exists a pair of distinct numbers in the list that add up to the target. In mathematical terms, you need to find two numbers \(a\) and \(b\) such that \(a + b = \text{target}\). If such a pair exists, output the two numbers (order does not matter) separated by a single space. Otherwise, print "No pair found".

Note: The program should read input from standard input (stdin) and produce output to standard output (stdout).

inputFormat

The input consists of three lines:

  1. The first line contains an integer \(n\) representing the number of elements in the list.
  2. The second line contains \(n\) space-separated integers.
  3. The third line contains an integer representing the target sum.

Example input:

5
1 2 3 4 5
6

outputFormat

If a valid pair exists, output the two integers separated by a single space. Otherwise, output "No pair found".

Example output for the sample input:

2 4
## sample
5
1 2 3 4 5
6
2 4