From 3105f5ca3396cf456afc8a87baf8a48e5b63563e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Fri, 1 Mar 2024 23:48:03 +0900 Subject: [PATCH 1/6] =?UTF-8?q?7=EC=B0=A8=EC=8B=9C=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YIM2UL2ET/README.md | 5 +++-- .../7\354\260\250\354\213\234 -BOJ 2705.cpp" | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 "YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" diff --git a/YIM2UL2ET/README.md b/YIM2UL2ET/README.md index 71c5f9a..a76b85f 100644 --- a/YIM2UL2ET/README.md +++ b/YIM2UL2ET/README.md @@ -6,6 +6,7 @@ | 2차시 | 2024.02.15 | 그리디 | [BOJ 1263](https://www.acmicpc.net/problem/1263) | [BOJ 1449 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/7) | | 3차시 | 2024.02.18 | 스택 | [BOJ 2504](https://www.acmicpc.net/problem/2504) | [BOJ 2504 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/9) | | 4차시 | 2024.02.21 | 덱 | [BOJ 1021](https://www.acmicpc.net/problem/1021) | [BOJ 1021 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/12) | -| 5차시 | 2024.02.21 | 큐 | [BOJ 1158](https://www.acmicpc.net/problem/1158) | [BOJ 1158 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/16) | -| 5차시 | 2024.02.21 | 정렬 | [BOJ 1599](https://www.acmicpc.net/problem/1599) | [BOJ 1599 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/21) | +| 5차시 | 2024.02.24 | 큐 | [BOJ 1158](https://www.acmicpc.net/problem/1158) | [BOJ 1158 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/16) | +| 6차시 | 2024.02.27 | 정렬 | [BOJ 1599](https://www.acmicpc.net/problem/1599) | [BOJ 1599 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/21) | +| 7차시 | 2024.03.01 | 재귀 | [BOJ 2705](https://www.acmicpc.net/problem/2705) | [BOJ 2705 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/23) | --- diff --git "a/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" new file mode 100644 index 0000000..f44c84c --- /dev/null +++ "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" @@ -0,0 +1,22 @@ +#include + +int ary[1000] = {0}; + +int solve(int n) +{ + if (n == 1) return 1; + else if (ary[n-1] != 0) return ary[n-1]; + for (int i = 0; n-i*2 > 1; i++) ary[n-1] += solve(i+1); + return ++ary[n-1]; +} + +int main(void) +{ + int n, input; + std::cin >> n; + for (int i = 0; i < n; i++) { + std::cin >> input; + std::cout << solve(input) << std::endl; + } + return 0; +} \ No newline at end of file From 5f4b652426dfa4527bf59f023738320f81dedbc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Sat, 2 Mar 2024 03:15:02 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../7\354\260\250\354\213\234 -BOJ 2705.cpp" | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git "a/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" index f44c84c..ec0d7bb 100644 --- "a/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" +++ "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" @@ -4,15 +4,16 @@ int ary[1000] = {0}; int solve(int n) { - if (n == 1) return 1; - else if (ary[n-1] != 0) return ary[n-1]; - for (int i = 0; n-i*2 > 1; i++) ary[n-1] += solve(i+1); + if (ary[n-1] != 0) return ary[n-1]; + for (int i = 0; n-i*2 > 1;) ary[n-1] += solve(++i); return ++ary[n-1]; } int main(void) { int n, input; + ary[0] = 1; + std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> input; From 9dfb20b5b1e7179966a46e856b1f938c288d3ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Mon, 4 Mar 2024 19:20:46 +0900 Subject: [PATCH 3/6] =?UTF-8?q?8=EC=B0=A8=EC=8B=9C=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YIM2UL2ET/README.md | 1 + .../7\354\260\250\354\213\234 - BOJ 2705.cpp" | 0 ...8\354\260\250\354\213\234 - BOJ 10994.cpp" | 42 +++++++++++++++++++ 3 files changed, 43 insertions(+) rename "YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" => "YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 - BOJ 2705.cpp" (100%) create mode 100644 "YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" diff --git a/YIM2UL2ET/README.md b/YIM2UL2ET/README.md index a76b85f..eaef663 100644 --- a/YIM2UL2ET/README.md +++ b/YIM2UL2ET/README.md @@ -9,4 +9,5 @@ | 5차시 | 2024.02.24 | 큐 | [BOJ 1158](https://www.acmicpc.net/problem/1158) | [BOJ 1158 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/16) | | 6차시 | 2024.02.27 | 정렬 | [BOJ 1599](https://www.acmicpc.net/problem/1599) | [BOJ 1599 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/21) | | 7차시 | 2024.03.01 | 재귀 | [BOJ 2705](https://www.acmicpc.net/problem/2705) | [BOJ 2705 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/23) | +| 8차시 | 2024.03.01 | 재귀 | [BOJ 10994](https://www.acmicpc.net/problem/10994) | [BOJ 10994 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/27) | --- diff --git "a/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 - BOJ 2705.cpp" similarity index 100% rename from "YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" rename to "YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 - BOJ 2705.cpp" diff --git "a/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" "b/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" new file mode 100644 index 0000000..369314c --- /dev/null +++ "b/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" @@ -0,0 +1,42 @@ +#include + +void func1(int n, int m) +{ + for (int i = 0; i < m; i++) std::cout << "* "; + for (int i = 0; i < 4*(n-1)+1; i++) std::cout << "*"; + for (int i = 0; i < m; i++) std::cout << " *"; + std::cout << "\n"; +} + +void func2(int n, int m) +{ + for (int i = 0; i < m; i++) std::cout << "* "; + std::cout << "*"; + for (int i = 0; i < 4*(n-1)-1; i++) std::cout << " "; + std::cout << "*"; + for (int i = 0; i < m; i++) std::cout << " *"; + std::cout << "\n"; +} + +void star(int n, int m) +{ + if (n == 1) { + for (int i = 0; i < (n+m)*2-1; i++) std::cout << "* "; + std::cout << "\n"; + } + else { + func1(n, m); + func2(n, m); + star(n-1, m+1); + func2(n, m); + func1(n, m); + } +} + +int main(void) +{ + int n; + std::cin >> n; + star(n, 0); + return 0; +} \ No newline at end of file From 59c0e154a199d3f6656bee798ee7ee038724b8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Wed, 6 Mar 2024 09:37:40 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=ED=95=A8=EC=88=98=20=EB=B0=8F=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...8\354\260\250\354\213\234 - BOJ 10994.cpp" | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git "a/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" "b/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" index 369314c..8728e2e 100644 --- "a/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" +++ "b/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" @@ -1,35 +1,35 @@ #include -void func1(int n, int m) +void cover1(int n, int level) { - for (int i = 0; i < m; i++) std::cout << "* "; - for (int i = 0; i < 4*(n-1)+1; i++) std::cout << "*"; - for (int i = 0; i < m; i++) std::cout << " *"; + for (int i = 0; i < level; i++) std::cout << "* "; + for (int i = 0; i < 4*(n-level)-3; i++) std::cout << "*"; + for (int i = 0; i < level; i++) std::cout << " *"; std::cout << "\n"; } -void func2(int n, int m) +void cover2(int n, int level) { - for (int i = 0; i < m; i++) std::cout << "* "; + for (int i = 0; i < level; i++) std::cout << "* "; std::cout << "*"; - for (int i = 0; i < 4*(n-1)-1; i++) std::cout << " "; + for (int i = 0; i < 4*(n-level)-5; i++) std::cout << " "; std::cout << "*"; - for (int i = 0; i < m; i++) std::cout << " *"; + for (int i = 0; i < level; i++) std::cout << " *"; std::cout << "\n"; } -void star(int n, int m) +void star(int n, int level) { - if (n == 1) { - for (int i = 0; i < (n+m)*2-1; i++) std::cout << "* "; - std::cout << "\n"; + if (n == level+1) { + for (int i = 0; i < n*2-2; i++) std::cout << "* "; + std::cout << "*\n"; } else { - func1(n, m); - func2(n, m); - star(n-1, m+1); - func2(n, m); - func1(n, m); + cover1(n, level); + cover2(n, level); + star(n, level+1); + cover2(n, level); + cover1(n, level); } } From 43d31fe627fd8904cdc142a568211c9c4f41a7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Thu, 7 Mar 2024 21:27:07 +0900 Subject: [PATCH 5/6] =?UTF-8?q?9=EC=B0=A8=EC=8B=9C=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YIM2UL2ET/README.md | 3 +- .../9\354\260\250\354\213\234 - BOJ 1914.cpp" | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 "YIM2UL2ET/\354\236\204\354\235\230 \354\240\225\353\260\200\353\217\204, \355\201\260 \354\210\230 \354\227\260\354\202\260/9\354\260\250\354\213\234 - BOJ 1914.cpp" diff --git a/YIM2UL2ET/README.md b/YIM2UL2ET/README.md index eaef663..3927de4 100644 --- a/YIM2UL2ET/README.md +++ b/YIM2UL2ET/README.md @@ -9,5 +9,6 @@ | 5차시 | 2024.02.24 | 큐 | [BOJ 1158](https://www.acmicpc.net/problem/1158) | [BOJ 1158 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/16) | | 6차시 | 2024.02.27 | 정렬 | [BOJ 1599](https://www.acmicpc.net/problem/1599) | [BOJ 1599 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/21) | | 7차시 | 2024.03.01 | 재귀 | [BOJ 2705](https://www.acmicpc.net/problem/2705) | [BOJ 2705 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/23) | -| 8차시 | 2024.03.01 | 재귀 | [BOJ 10994](https://www.acmicpc.net/problem/10994) | [BOJ 10994 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/27) | +| 8차시 | 2024.03.04 | 재귀 | [BOJ 10994](https://www.acmicpc.net/problem/10994) | [BOJ 10994 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/27) | +| 9차시 | 2024.03.07 | 임의 정밀도 / 큰 수 연산 && 재귀 | [BOJ 1914](https://www.acmicpc.net/problem/1914) | [BOJ 1914 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/29) | --- diff --git "a/YIM2UL2ET/\354\236\204\354\235\230 \354\240\225\353\260\200\353\217\204, \355\201\260 \354\210\230 \354\227\260\354\202\260/9\354\260\250\354\213\234 - BOJ 1914.cpp" "b/YIM2UL2ET/\354\236\204\354\235\230 \354\240\225\353\260\200\353\217\204, \355\201\260 \354\210\230 \354\227\260\354\202\260/9\354\260\250\354\213\234 - BOJ 1914.cpp" new file mode 100644 index 0000000..72499be --- /dev/null +++ "b/YIM2UL2ET/\354\236\204\354\235\230 \354\240\225\353\260\200\353\217\204, \355\201\260 \354\210\230 \354\227\260\354\202\260/9\354\260\250\354\213\234 - BOJ 1914.cpp" @@ -0,0 +1,40 @@ +#include + +std::string FindValue(int n) +{ + std::string result = "1"; + for (int i = 0; i < n; i++) { + for (int j = 0; j < result.size(); j++) { + result[j] = (result[j] - '0') * 2 + '0'; + if (result[j] > '9') { + result[j] -= 10; + if (j == 0) result.insert(result.begin(), '1'), j++; + else result[j-1]++; + } + } + } + result[result.size()-1]--; + return result; +} + +void Hanoi(int level, int start, int between, int end) +{ + std::ios_base::sync_with_stdio(false); + std::cout.tie(NULL); + + if (level == 1) std::cout << start << " " << end << "\n"; + else { + Hanoi(level-1, start, end, between); + std::cout << start << " " << end << "\n"; + Hanoi(level-1, between, start, end); + } + return; +} + +int main(void) { + int n; + std::cin >> n; + std::cout << FindValue(n) << "\n"; + if (!(n > 20)) Hanoi(n, 1, 2, 3); + return 0; +} \ No newline at end of file From 2de2f15f82e0e39a337156cdb9594c49831d29e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Fri, 8 Mar 2024 01:06:11 +0900 Subject: [PATCH 6/6] =?UTF-8?q?9=EC=B0=A8=EC=8B=9C=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../9\354\260\250\354\213\234 - BOJ 1914.cpp" | 3 --- 1 file changed, 3 deletions(-) diff --git "a/YIM2UL2ET/\354\236\204\354\235\230 \354\240\225\353\260\200\353\217\204, \355\201\260 \354\210\230 \354\227\260\354\202\260/9\354\260\250\354\213\234 - BOJ 1914.cpp" "b/YIM2UL2ET/\354\236\204\354\235\230 \354\240\225\353\260\200\353\217\204, \355\201\260 \354\210\230 \354\227\260\354\202\260/9\354\260\250\354\213\234 - BOJ 1914.cpp" index 72499be..e870bff 100644 --- "a/YIM2UL2ET/\354\236\204\354\235\230 \354\240\225\353\260\200\353\217\204, \355\201\260 \354\210\230 \354\227\260\354\202\260/9\354\260\250\354\213\234 - BOJ 1914.cpp" +++ "b/YIM2UL2ET/\354\236\204\354\235\230 \354\240\225\353\260\200\353\217\204, \355\201\260 \354\210\230 \354\227\260\354\202\260/9\354\260\250\354\213\234 - BOJ 1914.cpp" @@ -19,9 +19,6 @@ std::string FindValue(int n) void Hanoi(int level, int start, int between, int end) { - std::ios_base::sync_with_stdio(false); - std::cout.tie(NULL); - if (level == 1) std::cout << start << " " << end << "\n"; else { Hanoi(level-1, start, end, between);