출처
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14dUIaAAUCFAYD
풀이
#include<bits/stdc++.h>
using namespace std;
int customPow(int N, int M) {
if (M == 0) {
return 1;
}
else {
return N * customPow(N, M - 1);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
for (int t = 1; t <= 10; t++) {
int T, N, M, result;
cin >> T;
cin >> N >> M;
result = customPow(N, M);
cout << "#" << T << " " << result << endl;
}
}
반응형
'알고리즘' 카테고리의 다른 글
[C++] SWEA 정곤이의 단조 증가하는 수 (0) | 2024.11.16 |
---|---|
[C++] SWEA 0/1 Knapsack (0) | 2024.11.15 |
[C++] SWEA 최장 경로 (0) | 2024.11.13 |
[C++] SWEA 행렬정렬 (1) | 2024.11.13 |
[C++] SWEA [모의 SW 역량테스트] 미생물 격리 (1) | 2024.11.13 |