728x90
반응형
풀이 :
재귀함수 호출 -> m이 점차 감소하면서 0이되면 return
Code
public class Solution1217 {
static int res, N, M;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
for (int tc = 1; tc <= 10; tc++) {
int T = sc.nextInt();
N = sc.nextInt();
M = sc.nextInt();
res = 1;
pow(N, M);
System.out.println("#" + T + " " + res);
}
}
private static void pow(int n, int m) {
if (m == 0) {
return;
}
res *= n;
pow(n, m - 1);
}
}
728x90
반응형
'SWEA' 카테고리의 다른 글
swea 1221 [D3] [S/W 문제해결 기본] 5일차 - GNS JAVA (1) | 2023.11.24 |
---|---|
swea 1220 [D3] [S/W 문제해결 기본] 5일차 - Magnetic JAVA (1) | 2023.11.24 |
swea 1216 [D3] [S/W 문제해결 기본] 3일차 - 회문2 JAVA (0) | 2023.11.24 |
swea 1215 [D3] [S/W 문제해결 기본] 3일차 - 회문1 JAVA (0) | 2023.11.24 |
swea 1213 [D3] [S/W 문제해결 기본] 3일차 - String JAVA (0) | 2023.11.22 |