problem code: IRSTXOR
i tried following code but it is giving me time limit exceeded error even with time complexity N.and this code is from their official editorial
βββ
#include
#include
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(tβ)
{
int d;
long long a,b,c;
int id=0;
int f=1;
for(int i=31;i>=0;i--)
{
if((1<<i)&c)
{
id=i;
break;
}
}
for(int i=id;i>=0;i++)
{
if((1<<i)&c)
{
if(f)
{
a|=1<<i;
f=0;
}
else
{
b|=1<<i;
}
}
else
{
a|=1<<i;
b|=1<<i;
}
}
cout<<a*b<<endl;
}
return 0;
}
ββ