728x90

https://swexpertacademy.com/main/talk/solvingClub/problemView.do

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


코드

def myPow(N,M):
    global n,m,answer
    if M == m:
        answer = N
        return
    myPow(N*n, M+1)
     
for _ in range(10):
    t = int(input())
    n,m = map(int,input().split())
    myPow(n,1)
    print("#%d" %t, answer)

풀이

재귀함수로 거듭제곱을 구현하라는 쉬운 문제였다.

SWEA 를 처음 써봐서 import sys가 안된다는 것도 몰랐다. ㅎㅎ...

여기서는 input() 사용하자.

'알고리즘 문제 풀이 > SWEA' 카테고리의 다른 글

[SWEA] 1491. 원재의 벽 꾸미기 python  (0) 2022.05.28

+ Recent posts