Problem Code:CENS20D Priya and AND

#include <iostream>
using namespace std;
int main() {
	int T,N[100],B,i=0,count=0;
	cin>>T;
	while(T>0)
	{
	    cin>>B;
	    while(i<B)
	    {
	        cin>>N[i];
	        i++;
	    }
	    i=0;
	    B=B-1;
	    while(i<B)
	    {
	        int j=0;
	        while(j!=B)
	        {
	            if(N[j]==N[B])
	            {
	            count+=1;
	            }
	            j++;
	        }
	        B--;
	    }
	    cout<<count<<"\n";
	    T=T-1;
	    i=0;
	    count=0;
	}
	return 0;
}

This is my code for the Priya and AND program it is working with every example i tried but it says Wrong. Why??

try brute force

Couldn’t get it. Elaborate please. The only Bruteforce i know is the cracking one. So i am not sure how can i use bruteforce here, I ain’t finding the locked key to my program.

https://www.codechef.com/viewsolution/36998352

but why is it showing my code wrong it works the same. i mean gives the same result.

Fron what i can get from your code(sorry if i didn’t catch your logic), you are assuming that for A&B == A, A must be equal to B. Try 1&5 and see if this is true

1 as a test case and 5 as a no of values, right?

Can anyone check why my code is showing error??

https://www.codechef.com/viewsolution/37009684

I meant using bitwise AND on 1 and 5

#include <iostream>
using namespace std;
int main() {
	int T,N[100],B,i=0,count=0;
	cin>>T;
	while(T>0)
	{
	    cin>>B;
	    while(i<B)
	    {
	        cin>>N[i];
	        i++;
	    }
	    i=0;
	    while(i<B)
	    {
	        int j=i+1;
	        while(j<B)
	        {
	            if((N[i]&N[j])==N[i])
	            {
	            count+=1;
	            }
	            j++;
	        }
	        i++;
	    }
	    cout<<count<<"\n";
	    T=T-1;
	    i=0;
	    count=0;
	}
	return 0;
}

thanks its done. I actually instead of using bitwise AND, I was just comparing the values stored at particular position in the array.

You, didn’t read editorial did you ?

Yea. My fault . Sorry.

I said that to siddhant rout , look for arrow at the top right.

ohh…again sorry …LOL