#K90952. Find the Unique Number
Find the Unique Number
Find the Unique Number
You are given a sequence of n integers, where every number appears exactly twice except for one number, which appears only once. Your task is to find and output that unique number.
The solution leverages the bitwise XOR operation. Recall that for any two numbers a and b, the property of XOR is given by:
\( a \oplus b = c \)
and particularly:
- \( a \oplus a = 0 \)
- \( 0 \oplus a = a \)
Thus, by XOR-ing all the numbers in the sequence, the duplicate pairs cancel out, leaving the unique number as the result.
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains an integer n (\(1 \le n \le 10^5\)), which represents the total number of elements in the sequence. Note that \(n\) is always odd.
- The second line contains n space-separated integers representing the sequence.
outputFormat
Output a single integer on stdout which is the number that appears only once in the sequence.
## sample1
1
1