티스토리 뷰
https://www.acmicpc.net/problem/1463
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <iostream> #include <algorithm> #include <cstring> using namespace std; #define INF 9999999 int dp[1000001]; : Memoization void divide(int x, int cnt) { if (dp[x] < cnt) return; if (cnt != 0)dp[x] = min(dp[x], cnt); if (x == 1) return; Overlapping : if (x % 3 == 0) divide(x / 3, cnt + 1); if (x % 2 == 0) divide(x / 2, cnt + 1); divide(x - 1, cnt + 1); } int main() { int t; cin >> t; memset(dp, INF, sizeof(dp)); divide(t, 0); cout << dp[1]; } | cs |
'알고리즘 > DP' 카테고리의 다른 글
BOJ)11052 붕어빵 판매하기(다시보기) (0) | 2017.06.20 |
---|---|
BOJ)9095 1, 2, 3 더하기 (0) | 2017.06.20 |
BOJ)11727 2xn 타일링 2 (0) | 2017.06.20 |
BOJ)11726 2xn 타일링(다시 보기) (0) | 2017.06.20 |
DP(Dynamic Programing) (0) | 2017.06.20 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 생활코딩
- MVVM
- FEED
- 백준온라인
- CollectionView
- CustomCollectionViewCell
- C++
- 코딩야학
- Cell Animation
- 데이터 바인딩
- UIView Animation
- 객체
- Grid
- Add TapGesture
- listview
- WPF
- DP
- dfs
- command
- Fakebook
- BFS
- 그래프
- 타일링
- Custom Cell
- BOJ
- 백준
- 스택
- XAML
- 문자열
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함