Hide

Problem B
Square and Multiply

Languages en is

Implement a memory efficient version of the square and multiply algorithm.

Input

Input is three lines. The first line contains the integer g. The second line contains the integer A. The third line contains the integer N. It is guaranteed that 1g,N109 and 0A1018.

Output

Output one line with the integer gA(modN).

Sample Input 1 Sample Output 1
3
53
356
75
Hide

Please log in to submit a solution to this problem

Log in