
You are given non-negative integers
less than
. For each of them, you
are to find the maximum possible Hamming distance between it and some other element
of the array
.
The Hamming distance of two non-negative integers is defined as the number of positions in the binary representation of these numbers in which they differ (we add leading zeros if necessary).
Formally, for each , calculate:
Input Specification
The first line contains two integers, and
.
The second line contains integers,
.
Output Specification
Output integers separated with spaces, where the
-th integer is the maximum Hamming distance
between
and some other number in
.
Constraints
Subtask | Points | Constraints |
---|---|---|
1 | 20 | |
2 | 25 | |
3 | 25 | No additional constraints. |
Sample Input 1
4 4
9 12 9 11
Sample Output 1
2 3 2 3
Sample Input 2
4 4
5 7 3 9
Sample Output 2
2 3 2 3
Sample Input 3
4 4
3 4 6 10
Sample Output 3
3 3 2 3
Explanation for Sample 3
The numbers can be represented as
in binary. Numbers
and
differ at
places, same as numbers
and
. On the other hand, the number
differs in at most
places from all
other numbers.
Comments