题目描述
仅供参考
样例
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] s = br.readLine().split(" ");
long a = Integer.parseInt(s[0]);
long b = Integer.parseInt(s[1]);
long c = Integer.parseInt(s[2]);
System.out.println(f(a, b, c));
}
//a^k % p
private static long f(long a, long k, long p) {
long res = 1%p;
while (k!=0){
if ((k&1)!=0){
res = res*a%p;
}
k >>=1;
a = a*a%p;
}
return res;
}
}