#P17332. 「TPOI-2B」AND and Subsequence
「TPOI-2B」AND and Subsequence
Problem Description
Given a sequence of length . Define one operation as follows: choose an interval , let . For any such that , set . Ask: what is the minimum number of operations needed to make all numbers in the sequence become ?
Here, denotes bitwise AND.
Input Format
This problem has multiple test cases.
The first line contains a positive integer , which denotes the number of test cases.
For each test case:
The first line contains a positive integer .
The second line contains non-negative integers .
Output Format
For each test case, output one integer per line, which is the answer.
4
4
1 2 3 1
4
1 2 2 2
4
0 1 1 0
4
1 0 2 4
3
2
1
3
Hint
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that .
For another of the testdata, it is guaranteed that .
For another of the testdata, it is guaranteed that are generated uniformly at random within the value range.
For of the testdata, it is guaranteed that , , .
Translated by ChatGPT 5