PS/분할 정복
[백준][분할 정복] No.1629_곱셈 完
_빌런
2023. 5. 22. 19:08
# ---------- Import ----------
import sys
input = sys.stdin.readline
# ---------- Function ---------
def POW(A, B, C):
if B == 1:
return A % C
tmp = POW(A, B//2, C)
if B % 2 == 0:
return (tmp * tmp % C)
else:
return (tmp * tmp * A % C)
# ---------- Main ----------
A, B, C = map(int, input().split())
result = POW(A, B, C)
print(result)