Created
January 7, 2017 01:57
-
-
Save dudelson/ccc52050195c5e3fd0225e8bd0ec15f9 to your computer and use it in GitHub Desktop.
My solution for UVA 11933
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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