Minimum Non-Zero Product of the Array Elements
You are given a positive integer p. Consider an array nums (1-indexed) that consists of the integers in the inclusive range [1, 2^p - 1] in their binary representations.
You are allowed to perform the following operation any number of times:
- Choose two elements
xandyfromnums. - Choose a bit in
xand swap it with its corresponding bit iny; corresponding bit means the bit in the same position in the other integer.
Find the minimum non-zero product of nums after performing the operation any number of times. Return this product modulo 10^9 + 7.
Note: The answer should be the minimum product before the modulo operation is done.
Example 1
Input
p = 1Output
1There is only one element, so the product equals that element.
Example 2
Input
p = 2Output
6Any swap would either make the product 0 or keep the same product, so 1 * 2 * 3 = 6 is already minimized.
Constraints
- 1 <= p <= 60