Skip to content

Instantly share code, notes, and snippets.

@dudelson
Created January 7, 2017 01:57
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 dudelson/ccc52050195c5e3fd0225e8bd0ec15f9 to your computer and use it in GitHub Desktop.
Save dudelson/ccc52050195c5e3fd0225e8bd0ec15f9 to your computer and use it in GitHub Desktop.
My solution for UVA 11933
#include <cstdio>
using namespace std;
typedef long long ll;
ll a, b, n, i;
bool e;
int main() {
while(scanf("%lld", &n), n) {
a = 0, b = 0, i = 0, e = true;
while(1LL<<i <= n) {
if(n&(1LL<<i) && e) {
a |= 1LL<<i;
e = !e;
} else if(n&(1LL<<i) && !e) {
b |= 1LL<<i;
e = !e;
}
i++;
}
printf("%lld %lld\n", a, b);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment