Skip to content

Instantly share code, notes, and snippets.

@zhrkvl
Last active December 15, 2016 10:52
Show Gist options
  • Save zhrkvl/5969f0fc4d098a815c7f44c1f83b1481 to your computer and use it in GitHub Desktop.
Save zhrkvl/5969f0fc4d098a815c7f44c1f83b1481 to your computer and use it in GitHub Desktop.
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