Skip to content

Commit

Permalink
Update code and README.md file
Browse files Browse the repository at this point in the history
1463_1로 만들기
  • Loading branch information
witheunjin committed Mar 11, 2020
1 parent ecfb6c3 commit b6b0dcf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions BaekJoon/1463_1로만들기.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
#include <algorithm>
using namespace std;

int cache[111];
int calc(int n) {
int& ret = cache[n];
if (ret != -1) return ret;
if (n == 1) return 0;
if (n % 3 == 0 && n % 2 == 0)
return ret = 1 + min(calc(n/3),calc(n/2));
if (n % 3 == 0) return ret = 1 + min(calc(n / 3), calc(n - 1));
if (n % 2 == 0) return ret = 1 + min(calc(n / 2), calc(n - 1));
return ret = 1 + calc(n - 1);
}
int main() {
memset(cache, -1, sizeof(cache));
int N;
cin >> N;
cout << calc(N) << endl;
return 0;
}
1 change: 1 addition & 0 deletions BaekJoon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ https://www.acmicpc.net/
---
| 문제번호 | 문제이름 | 날짜 | 시도횟수|
|:-----:|:-----:|:--:|:-----:|
| **1463**|**1로 만들기**|2020.03.1|3|
| **10828**|**스택** |2020.03.03|1|
| **10845**|****|2020.03.03|1|
| **9012**|**괄호** |2020.03.03|1|

0 comments on commit b6b0dcf

Please sign in to comment.