// 1. 10만개짜리 거리 배열 만들기
int dist[100001];

int main() {
    // 2. N, K 입력받기

    // 3. 큐 만들고 시작점 N 넣기 (dist[N] 방문표시)

    while (/* 큐가 비어있지 않을 때까지 */) {
        int cur = /* 큐의 맨 앞 데이터 꺼내기 */;
        
        // 4. 세 가지 이동 방법 체크
        int next_options[3] = {cur - 1, cur + 1, cur * 2};
        for (int i = 0; i < 3; i++) {
            int next = next_options[i];
            
            // 만약 next가 범위(0~100,000) 안이고, 방문한 적 없다면?
            if (/* 조건문 채우기 */) {
                // 5. 큐에 넣고, dist[next] = dist[cur] + 1;
            }
        }
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: