#K38112. Unique Encoded Outputs Count
Unique Encoded Outputs Count
Unique Encoded Outputs Count
You are given an integer n, an integer key, and a list of n integers called codes. Your task is to determine the number of unique values obtained when each code is encoded using the bitwise XOR operation with the given key.
The XOR (exclusive OR) operation is a binary operation which, for two bits, returns 0 if they are the same and 1 otherwise. In mathematical notation, for a code c and key key, the encoded value is given by:
\( encoded = c \oplus key \)
After performing this operation on each code, count the number of distinct encoded values.
Example:
For n = 4, key = 5, and codes [17, 10, 20, 17], applying the XOR operation yields encoded values: [17 ⊕ 5, 10 ⊕ 5, 20 ⊕ 5, 17 ⊕ 5] = [20, 15, 17, 20]. The number of unique values is 3 (namely, 20, 15, and 17).
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains two space-separated integers: n (the number of codes) and key (the XOR key).
- The second line contains n space-separated integers representing the list of codes.
outputFormat
Output a single integer to standard output (stdout), which is the number of unique encoded outputs obtained after applying the XOR operation with the given key on each code.
## sample4 5
17 10 20 17
3