Problem
Input format
The program reads from standard input, separated by spaces, three natural numbers `x`, `n`, and `m`. - `0 <= x <= 1.000.000` - `0 <= n <= 1.000.000.000` - `1 <= m <= 1.000.000.007` - The solution must be recursive, with call depth of order `log2(n)`.
Output format
The program prints a single natural number: `(x^n) mod m`, followed by a newline.
Example
2 10 1000000
1024
Stuck?
Use the Get Hint button in the action bar to reveal a guided hint.
💬 Discussion
Loading...No comments yet. Be the first to start the discussion!
Sample cases (from the problem)
Sample Case 1
2 10 1000000
1024
Solve it your way first
Community solutions unlock after you submit a passing solution. Don't peek.
Ready to solve this challenge?
Create a free account to write code, submit solutions, and track your progress.