diff --git a/.gitignore b/.gitignore index dd5c568..73dcb74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store +.idea/ /.vscode diff --git a/g0rnn/README.md b/g0rnn/README.md index c427fa7..f8dcc1e 100644 --- a/g0rnn/README.md +++ b/g0rnn/README.md @@ -9,6 +9,7 @@ | 5차시 | 2024.11.01 | BFS/DFS | [연구소](https://www.acmicpc.net/problem/14502) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/17 | | 6차시 | 2024.11.06 | 구현 | [통계학](https://www.acmicpc.net/problem/2108) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/23 | | 7차시 | 2024.11.25 | 구현 | [팰린드롬 만들기](https://www.acmicpc.net/problem/1213) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/31 | -| 8차시 | 2024.11.29 | 문자열 | [잠수함식별](https://www.acmicpc.net/problem/2671) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/35 | +| 8차시 | 2024.11.29 | 문자열 | [잠수함식별](https://www.acmicpc.net/problem/2671) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/35 | +| 9차시 | 2024.12.04 | 그리디 | [A->B](https://www.acmicpc.net/problem/16953) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/39 | --- diff --git a/g0rnn/greedy/9-g0rnn.cpp b/g0rnn/greedy/9-g0rnn.cpp new file mode 100644 index 0000000..6f70e28 --- /dev/null +++ b/g0rnn/greedy/9-g0rnn.cpp @@ -0,0 +1,27 @@ +// +// Created by 김균호 on 2024. 12. 4.. +// +#include +using namespace std; + +int a, b, answer = 1; + +int main() { + cin >> a >> b; + + while (a < b) { + if (b % 2 == 0) { + b = b / 2; + } else if (b % 10 == 1) { + b /= 10; + } else { + break; + } + answer++; + } + + if(a == b) cout << answer; + else cout << -1; + + return 0; +} \ No newline at end of file