본문 바로가기
JAVA 알고리즘

SWEA 1217 (S/W 문제해결 기본) 4일차 - 거듭 제곱

by 잡다한 저장소 2019. 8. 16.
import java.util.*;
public class Solution {
	static Scanner sc  = new Scanner(System.in);
	static int mult(int n, int m) {
		if( m<2 ) return n;
		return n * mult(n, m-1);
	}
	public static void main(String[] args) {
		for(int i=1; i<=10; i++) {
			int tc = sc.nextInt();
			int N = sc.nextInt();
			int M = sc.nextInt();
			System.out.format("#%d %d\n", tc, mult(N, M));
		}
		sc.close();
	}
}