简洁题解
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long a = sc.nextLong(),b = sc.nextLong(),p = sc.nextLong();
long ans = 1%p;
for(;b!=0;b>>=1){
if((b&1)==1) ans = (long) ans *a %p;
a = a*a %p;
}
System.out.println(ans);
}
}