yeah you are right im talking abt that quesn only.... i got the power part but how could i store that F(n)(the gcd) part which is supposedly very large..?
On Fri, May 4, 2012 at 3:28 AM, shiv narayan <narayan.shiv...@gmail.com> wrote: > 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 <gpgaurav.n...@gmail.com> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.