Skip to content

Commit

Permalink
9차시 업로드
Browse files Browse the repository at this point in the history
  • Loading branch information
YIM2UL2ET committed Mar 7, 2024
1 parent 59c0e15 commit 43d31fe
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion YIM2UL2ET/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
---
40 changes: 40 additions & 0 deletions YIM2UL2ET/임의 정밀도, 큰 수 연산/9차시 - BOJ 1914.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>

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;
}

0 comments on commit 43d31fe

Please sign in to comment.