동적프로그래밍

    [class5] (백준 12852) 1로 만들기 2

    알고리즘 dp [문제 본문] 더보기 HTML 삽입 미리보기할 수 없는 소스 [푼 코드] #include #include #define MAXNUM 10000001 using namespace std; int N; int dp[MAXNUM]; int before[MAXNUM]; int main() { ios::sync_with_stdio(false); cin.tie(); cout.tie(); cin >> N; dp[1] = 0; before[1] = -1; for (int i = 2; i