# Priya and AND Solutions CENS20D

Page Contents

## Priya and AND Solutions

Priya adores bitwise AND, however she loathes programming. Assist her with taking care of this issue.

Given an exhibit An of size N, let Bij mean the bitwise AND of A[i] and A[j]. You need to locate the quantity of sets (i,j), with the end goal that i<j and Bij=A[i].

Info:

The principal line of the information contains a solitary whole number T signifying the quantity of experiments.

The primary line of each experiment comprises of a solitary whole number N, meaning the Size of Array A.

The second line of each experiment contains N space-isolated numbers A1,A2,A3…AN.

Yield:

For each experiment, yield a solitary line, check of such matches.

Imperatives

1≤T≤100

1≤N≤100

1≤A[i]≤100

Test Input:

1

10

Test Output:

10

Clarification

Model case 1: Number of substantial sets are – (1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5) and (4,5). Subsequently, absolute legitimate sets =10.

Model case 2: Since N=1, in this way there are no legitimate sets.

Solution

import java.util.*;

import java.math.*;

class CENS20D

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int t,i,j,n,c=0;

String str,s;

t=sc.nextInt();

while(t!=0)

{

n=sc.nextInt();

int arr[]=new int[n];

for(i=0;i<n;i++)

arr[i]=sc.nextInt();

for(i=0;i<n;i++)

for(j=i+1;j<n;j++)

if((arr[i]&arr[j])==arr[i])

c++;

System.out.println(c);

c=0;

t–;

}

}

}