#K64042. Minimum Bitwise AND of Contiguous Subsequence
Minimum Bitwise AND of Contiguous Subsequence
Minimum Bitwise AND of Contiguous Subsequence
You are given an integer n and an array of n integers. Your task is to compute the minimum bitwise AND value of any contiguous subsequence (subarray) of the given array.
A contiguous subsequence of the array is a segment of consecutive elements. The bitwise AND of a subset of numbers is defined as the result of applying the &
operator consecutively to all the numbers in that subsequence.
The problem guarantees that the input size is small enough for an O(n2) solution to pass. If the subsequence becomes 0 during computations, you can immediately return 0 as the minimum possible value.
For example, consider the case when n = 4 and the array is [5, 6, 7, 8]. By considering different contiguous segments, the minimum bitwise AND value is 0.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains a single integer n (1 ≤ n ≤ 105), representing the length of the array.
- The second line contains n space-separated integers, representing the elements of the array.
outputFormat
Output to standard output (stdout) a single integer — the minimum bitwise AND value of any contiguous subsequence of the array.
## sample1
5
5
</p>