does this solution will work?
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
//find x such that (a^x)*(b^x) is maximum
// and x should be less than pow(2,n);
int a=12;
int b=7;
int n=4;
int range=pow(2,n);
int maxprod=INT_MIN;
int ans=0;
int low=0,high=range-1;
while(low<=high)
{
int mid=low+(high-low)/2;
int prod=(a^mid)*(b^mid);
if(prod>=maxprod)
{
maxprod=prod;
ans=low;
high=mid-1;
}
else {
low=mid+1;
}
}
cout<<ans;
}