EQBYXOR - Editorial

Can anyone tell me any testcase which my code is failing on?

using namespace std;
int valueof(int a[])
{
    int total=0;
    for(int i=0;i<32;i++)
    {
        total+=a[i]*(pow(2,i));
    }
    return total;
}
int powsize(int a[])
{
    int i=31;
    while(a[i]==0)
    {
        i--;
    }
    return i;
}
void binary(int x,int p[])
{
    int i=0;
    while(x!=0)
    {
        p[i]=x%2;
        x=x/2;
        i++;
    }
}
int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    int a1[32]{0},b1[32]{0},r1[32]{0},n1[32]{0};
	    int a,b,n,v,sr,sn;
	    cin>>a>>b>>n;
	    n-=1;
	    binary(a,a1);
	    binary(b,b1);
	    binary(n,n1);
	    for(int i=0;i<32;i++)
	    {
	        if(a1[i]==b1[i])r1[i]=0;
	        else
	        r1[i]=1;
	    }
	    sr=powsize(r1);
	    sn=powsize(n1);
	    if(sn>=sr)
	    {
	        v=valueof(r1);
	        if(v==0)cout<<"0"<<endl;
	        else if(v<=n)cout<<"1"<<endl;
	        else
	        cout<<"2"<<endl;
	    }
	    else
	    cout<<"-1"<<endl;
	    
	    
	}
	return 0;
}

@umar321 - you can post this to the doubt solvers at CodeChef: Practical coding for everyone

you can say n is 21, if a ^ b is 20 then the output should be 1.
Your code output will be 2. test cases will give error