아무리 생각해도 시간초과를 발생시키지 않고 풀지 못하겠어서 검색하였다.
참고
#include <iostream>
long long getExponent(int a, int b, int c)
{
if (b == 0) {
return 1;
}
return (b % 2 == 1) ? (getExponent(a, b/2, c) * getExponent(a, b/2, c) % c * a % c) : (getExponent(a, b/2, c) * getExponent(a, b/2, c) % c);
}
int main(void)
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
printf("%lld\n", getExponent(a, b, c));
return 0;
}