#K42727. Find Unique Pairs with Target Sum
Find Unique Pairs with Target Sum
Find Unique Pairs with Target Sum
Given a list of integers and an integer target sum \(k\), your task is to find all unique pairs in the list that add up to \(k\). A pair \((a, b)\) is defined to satisfy \(a \leq b\) and should be printed in ascending order by its first element (and if equal, by its second). If no such pairs exist, output None
.
Constraints:
- The number of integers \(N\) is between 2 and 100.
- The target sum \(0 \leq k \leq 200\).
- Each integer is in the range \([-100, 100]\).
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains space-separated integers representing the list of numbers.
- The second line contains a single integer \(k\), the target sum.
outputFormat
For each unique pair \((a, b)\) that satisfies \(a+b=k\), output a line with the two numbers separated by a space. The pairs must be printed in ascending order. If no valid pairs exist, print None
.
1 2 3 4 5 6
7
1 6
2 5
3 4
</p>