Pow function for long data

llu pow1(llu x, llu y)
{
    llu temp;
    if(y == 0)
        return 1;
    temp = pow1(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}

Comments

Popular posts from this blog

C++ STL practice problem link

Binary Index Tree(BIT)

Combinatorics