Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
620 B
1
Indexable
Never
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        int an=arr[0];
        for(int i=0;i<n;i++){
            an=an & arr[i];
        }
        if(an!=0){
            cout<<1<<endl;
            continue;
        }
        int count=0;
        int temp=arr[0];
        for(int i=0;i<n;i++){
            temp=temp & arr[i];
            if(temp==an){
                count++;
                temp=arr[i+1];
            }
        }
        cout<<count<<endl;
    }
    return 0;
}