Binary exponentiation - MarisaOJ: Marisa Online Judge

Binary exponentiation

Time limit: 1000 ms
Memory limit: 256 MB
Given 3 integers $a, b, c$. Calculate: $$a ^ b \mod c$$ ### Input - The first line contains 3 integers $a, b, c$. ### Output - Print $a ^ b \mod c$. ### Constraints - $1 \le a, b, c \le 10^{18}$. ### Example Input: ``` 3 6 5 ``` Output: ``` 4 ```