Skip to content

Instantly share code, notes, and snippets.

@kemingy
Created June 7, 2016 12:36
Show Gist options
  • Select an option

  • Save kemingy/c62c9a0d5eef8905781a08716f330ced to your computer and use it in GitHub Desktop.

Select an option

Save kemingy/c62c9a0d5eef8905781a08716f330ced to your computer and use it in GitHub Desktop.
long long quick_pow(int e, int n)
{
long long ans = 1, tmp = e;
if(!e)
{
return 0;
}
while(n > 0)
{
if (n & 1 == 1)
{
ans *= tmp;
}
tmp = tmp * tmp;
n = n >> 1;
}
return ans;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment