An Exponentiation Problem

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Assembly, Awk, Brain****, C, C++, Clang, Clang++, COBOL, Coffee, D, Go, Haskell, Java, JS, Lisp, LOLCODE, Lua, Mono C#, Mono F#, NASM, NASM64, OCaml, Pascal, Perl, PHP, Processing, Python, Racket, Ruby, Rust, Sed, TCL, Text, Turing

Given the integers, N, M, P, find N^M\bmod P.

Input Specification

The first line will contain three integers, N, M, P (1 \le N, M \le 10^9, 1 \le P \le 2 \times 10^9).

Output Specification

Output N^M \bmod P.

Sample Input 1

3 6 11

Sample Output 1


Sample Input 2

123456789 987654321 998244353

Sample Output 2



There are no comments at the moment.