| 23 | } |
| 24 | |
| 25 | void solve(){ |
| 26 | int N; |
| 27 | cin>>N; |
| 28 | int A[N]; //init an array |
| 29 | int count = 0; //creating counter variable |
| 30 | for(int i = 0;i<N;i++){ |
| 31 | cin>>A[i]; //input all the integers |
| 32 | } |
| 33 | for(int i = 0;i<N;i++){ |
| 34 | for(int j=i+1 ; j<N ; j++){ |
| 35 | if((A[i]&A[j])==A[i]) //check if their bitwise AND matches the first operand |
| 36 | count++; //if yes the count this pair |
| 37 | } |
| 38 | } |
| 39 | cout<<count<<endl; //print the number of pairs |
| 40 | } |