diff --git a/oesnuj/DP/2775.cpp b/oesnuj/DP/2775.cpp deleted file mode 100644 index c7cf2e6..0000000 --- a/oesnuj/DP/2775.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/*풀이1 재귀만 이용*/ -//#include -//using namespace std; -// -//int calc(int k, int n) { -// if (k == 0) return n; -// int sum = 0; -// for (int i = n; i > 0; i--) { -// sum += calc(k - 1, i); -// } -// return sum; -//} -// -//int main() -//{ -// int T, k, n; -// cin >> T; -// while (T--) { -// cin >> k >> n; -// cout << calc(k, n) << "\n"; -// } -// return 0; -//} - -/*풀이2, 재귀 + DP*/ -#include -#include -using namespace std; - -vector> dp; - -int calc(int k, int n) { - if (k == 0) return n; - if (dp[k][n] != -1) return dp[k][n]; // 이미 계산된 값이면 반환 - - int sum = 0; - for (int i = n; i > 0; i--) { - sum += calc(k - 1, i); - } - return dp[k][n] = sum; // 계산된 값을 저장하고 반환 -} - -int main() -{ - int T, k, n; - cin >> T; - while (T--) { - cin >> k >> n; - dp = vector>(k + 1, vector(n + 1, -1)); //케이스별 DP 테이블 초기화 - cout << calc(k, n) << "\n"; - } - return 0; -} diff --git "a/oesnuj/\354\236\254\352\267\200/1914.cpp" "b/oesnuj/\354\236\254\352\267\200/1914.cpp" deleted file mode 100644 index 90b8165..0000000 --- "a/oesnuj/\354\236\254\352\267\200/1914.cpp" +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include -using namespace std; - -void RecurMoveDisks(int n, int from, int temp, int to) { - if (n == 0) return; - //n-1개의 원판으로 temp로 옮긴다. - RecurMoveDisks(n - 1, from, to, temp); - - //남은 1개의 원판으로 to로 옮긴다. <- 이때 옮기는 과정 출력 - cout << from << " " << to << "\n"; - - //temp에 있던 n-1개의 원판을 n-1개로 옮긴다. - RecurMoveDisks(n - 1, temp, from, to); -} - -int main() { - ios::sync_with_stdio(false); cin.tie(nullptr); - int n; - cin >> n; - - //2의 n제곱 -1 출력하기 - string cnt = to_string(pow(2, n)); - int x = cnt.find('.'); - cnt = cnt.substr(0, x); - cnt[cnt.length() - 1] -= 1; - cout << cnt << "\n"; - - //조건에 맞는 경우에만 재귀를 돌린다. - if (n <= 20) RecurMoveDisks(n, 1, 2, 3); - return 0; -} \ No newline at end of file