#C9236. Find Pair With Zero Sum
Find Pair With Zero Sum
Find Pair With Zero Sum
Given a list of integers, your task is to find a pair of numbers that sum to zero. If such a pair exists, output the pair as two integers separated by a space, where the first number is the additive inverse of the second. If there are multiple valid pairs, any one is acceptable. If no such pair exists, output None
.
For example, given the list [2, -3, 1, -1, 3], one valid answer is 1 -1
because 1 + (-1) = 0.
inputFormat
The input is read from standard input. The first line contains an integer n which indicates the number of elements in the list. The second line contains n space-separated integers.
outputFormat
The output is written to standard output. If a pair is found, print the two integers separated by a space (i.e. if the pair is (a, b), print a b
). If no such pair exists, print None
.
5
2 -3 1 -1 3
1 -1