#P9178. Maximum Hamming Distance for Array Elements
Maximum Hamming Distance for Array Elements
Maximum Hamming Distance for Array Elements
Given an array of n non-negative integers where each integer is less than , your task is to compute, for every element, the maximum Hamming distance between it and any other element in the array. The Hamming distance between two non-negative integers is defined as the number of positions where their -bit binary representations (with leading zeros if necessary) differ.
Formally, for each (1 ≤ i ≤ n), compute:
$$\max_{1\leq j\leq n} \text{hamming}(a_i,a_j)$$
inputFormat
The first line contains two integers and .
The second line contains non-negative integers , each less than .
outputFormat
Output integers separated by spaces, where the -th integer is the maximum Hamming distance between and any element in the array (including itself).
sample
3 3
5 4 0
2 2 2