Baekjoon #1463

Baekjoon #1463

1개의 풀이 · C++

문제 원문 보기 ↗

SOLUTION INFO

C++ · main.cpp

main.cpp
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char** argv)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N;
    cin >> N;

    vector<int> count(N + 1);
    count[1] = 0;

    for(int i = 2; i < N + 1; ++i) {
        count[i] = count[i - 1] + 1;
        if (i % 2 == 0) {
            count[i] = min(count[i], count[i / 2] + 1);
        }
        if (i % 3 == 0) {
            count[i] = min(count[i], count[i / 3] + 1);
        }
    }

    cout << count[N] << '\n';

    return 0;
}

SOLUTION DESCRIPTION

풀이 설명

등록된 풀이 설명이 없습니다.