티스토리 뷰

A = int(input())
X = int(input())

arr = [A]
exp = 1
while True:
    exp *= 2
    if X < exp:
        break
    arr.append((arr[-1] ** 2) % 1000000007)
    
def decompose_bin(x):
    result = []
    power = 0
    
    while x > 0:
        if x % 2 == 1:
            result.append(power)
        x //= 2
        power += 1
        
    return result

def solution(A, X):
    X_bin = decompose_bin(X)

    ans = 1
    for b in X_bin:
        ans *= (arr[b])
    return ans % 1000000007
    
print(solution(A, X))

A, B, C = map(int, input().split())

arr = [A]
exp = 1
while True:
    exp *= 2
    if B < exp:
        break
    arr.append((arr[-1] ** 2) % C)

def decompose_bin(x):
    result = []
    power = 0

    while x > 0:
        if x % 2 == 1:
            result.append(power)
        x //= 2
        power += 1

    return result

B_bin = decompose_bin(B)
ans = 1
for b in B_bin:
    ans *= arr[b]

print(ans % C)
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함