题目描述
Problem Description
Given \( n \) non-negative integers \( a_1, a_2, \cdots, a_n \), you need to determine a non-negative integer \( x \) such that \( a_1 \oplus a_2 \oplus \cdots \oplus a_n \oplus x \) is minimized.
You need to calculate \( x \) and \( a_1 \oplus a_2 \oplus \cdots \oplus a_n \oplus x \).
Here, \( \oplus \) represents the XOR operation, where \( x \oplus y \) can be expressed as x ^ y in C++. For two non-negative integers \( x \) and \( y \), their XOR is obtained by performing the following operation on each bit of their binary representations:
- If the bits of \( x \) and \( y \) are different, the result bit is 1;
- If the bits of \( x \) and \( y \) are the same, the result bit is 0.
For example: \( 0 \oplus 0 = 0 \), \( 1 \oplus 0 = 1 \), \( 0 \oplus 1 = 1 \), \( 1 \oplus 1 = 0 \).
Input Format
The input consists of two lines.
The first line contains an integer \( n \), representing the length of the sequence \( a \).
The second line contains \( n \) integers \( a_1, a_2, \cdots, a_n \), representing the sequence \( a \).
Output Format
Output a single line containing two integers \( x \) and \( a_1 \oplus a_2 \oplus \cdots \oplus a_n \oplus x \).
Sample Input and Output
Sample Input #1
2
1 2
Sample Output #1
3 0
Sample Input #2
2
7 7
Sample Output #2
0 0
Notes
Data Size and Constraints
For \( 100\% \) of the data, \( 1 \leq n \leq 10^6 \), \( 0 \leq a_i \leq 10^{18} \).
| Test Case | \( n \) | \( a_i \) | Special Properties |
|---|---|---|---|
| 1 | \( = 1 \) | \( \leq 10^3 \) | None |
| 2 | \( = 2 \) | \( \leq 10^3 \) | \( a_1 = a_2 \) |
| 3 \~ 4 | \( = 2 \) | \( \leq 10^3 \) | None |
| 5 | \( \leq 10^3 \) | \( = 0 \) | None |
| 6 \~ 8 | \( \leq 10^3 \) | \( \leq 10^3 \) | None |
| 9 \~ 11 | \( \leq 10^6 \) | \( \leq 10^3 \) | None |
| 12 \~ 13 | \( \leq 10^6 \) | \( \leq 1 \) | None |
| 14 \~ 20 | \( \leq 10^6 \) | \( \leq 10^{18} \) | None |
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分