You are viewing a single comment's thread. Return to all comments →
Python: This solution works for values of k which do not lead to overflow when calculating: a^k and similarly large values.
a^k
def solve(a, b, k, m): complex_num = complex(a, b) ** k lst = map(int, [complex_num.real, complex_num.imag]) return list(map(lambda x: x % m, lst))
Seems like cookies are disabled on this browser, please enable them to open this website
Russian Peasant Exponentiation
You are viewing a single comment's thread. Return to all comments →
Python: This solution works for values of k which do not lead to overflow when calculating:
a^k
and similarly large values.