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] =?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