My issue
include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
long long x;
cin>>x;
if(x==1)
{
cout<<(x+1)<<" “<<x+2<<endl;
continue;
}
if(x%2==1)
{
cout<<(x&(x-1))<<” “<<1<<endl;
}
else
{
if(x & (x - 1))
cout<<(x&(x-1))<<” “<<x-(x&(x-1))<<endl;
else
{
cout<<(x<<1ll)<<” "<<x<<endl;
}
}
}
return 0;
}
what is wrong here? why isn’t it working
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
long long x;
cin>>x;
if(x==1)
{
cout<<(x+1)<<" "<<x+2<<endl;
continue;
}
if(x%2==1)
{
cout<<(x&(x-1))<<" "<<1<<endl;
}
else
{
if(x & (x - 1))
cout<<(x&(x-1))<<" "<<x-(x&(x-1))<<endl;
else
{
cout<<(x<<1ll)<<" "<<x<<endl;
}
}
}
return 0;
}
Problem Link: XOR And Multiply Practice Coding Problem - CodeChef