Last active
December 15, 2016 10:52
-
-
Save zhrkvl/5969f0fc4d098a815c7f44c1f83b1481 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
ll memeficate(ll r) | |
{ | |
ll x = 0; | |
for(int i = 1; i < 62; i += 2) | |
x |= bool((r & (1ll << i))) << (i >> 1); | |
return x; | |
} | |
ll cnt(ll r) | |
{ | |
int p = 60; | |
for(; p >= 0 && !((1ll << p) & r); p -= 2); | |
if(p < 0) | |
return memeficate(r); | |
p--; | |
for(; p >= 0; p -= 2) | |
r |= (1ll << p); | |
return memeficate(r); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment