1217. [S/W 문제해결 기본] 4일차 - 거듭 제곱


문제링크

[풀이]

#include <iostream>
using namespace std;

int T, N, M, sol;

void solve(int depth, int num) {
	if (depth >= M) {
		sol = num;
		return;
	}
	solve(depth + 1, num * N);
}

int main() {
	for (int i = 1; i <= 10; i++) {
		cin >> T;

		cin >> N >> M;

		solve(1, N);

		cout << "#" << T << " " << sol << "\n";
	}
}





© 2020.02. by blupine