Skip to content

Instantly share code, notes, and snippets.

@OmarJH
Created May 2, 2015 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OmarJH/212a1e882b2fec0f670e to your computer and use it in GitHub Desktop.
Save OmarJH/212a1e882b2fec0f670e to your computer and use it in GitHub Desktop.
ACM - EC_CONB - Even Numbers - SPOJ
#include <iostream>
using namespace std;
int main()
{
int t, x,tem,tem2;
cin >> t;
while (t--)
{
tem = 0;;
cin >> x;
if (x % 2 != 0)
{
cout << x << endl;
continue;
}
while (x != 0)
{
tem = tem << 1;
tem = tem + (x & 1);
x = x >> 1;
}
cout << tem << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment