We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Russian Peasant Exponentiation
Russian Peasant Exponentiation
Sort by
recency
|
47 Discussions
|
Please Login in order to post a comment
Python code:
The problem relates to the Binary and Modular exponentiation. This requires the knowledge of complex number multiplication as well
Python: This solution works for values of k which do not lead to overflow when calculating:
a^k
and similarly large values.Do not bother using Python3, use PyPy3 as your language. Otherwise you will get test timeouts.
C# doesnt take care of negative module result:
...need to take care yourself