it looks you are talking about unlock 1 or 2 on spoj, use your own
recursive power  function and since result may be very large so at
every stage take  mod.
pow(a,b)
{
if(b==1)
return a;
else
{
if(b%2==0)
return (pow(a,b/2)%mod *pow(a,b/2)%mod) %mod
else
return ((((pow(a,b/2)%mod *pow(a,b/2)%mod) %mod)*a)%mod)))  //check
parenthesis
}
}

On Apr 29, 7:20 pm, Gaurav Popli <[email protected]> wrote:
> givenn gcd of two integers a and b,..
> you hvae to find max value of a^b%mod where mod is also given...

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to