시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB60434072.727%

문제

Imagine a very simple text editor that supports exactly two operations:

  • Copy All : Copy the entire current screen content into the clipboard. (Partial copy is not allowed.)
  • Paste : Paste the content from the clipboard onto the screen.

Initially, the screen contains a single character A. Your goal is to display exactly $N$ characters A on the screen using the minimum number of operations possible. Find the minimum number of operations required when acting optimally.

입력

The first line contains a single integer $N$, representing the number of characters A to be displayed. $(1 \leq N \leq 1\,000\,000)$

출력

Print a single integer: the minimum number of operations required.

서브태스크

번호배점제한
180

$1 \leq N \leq 1\,000$

220

$1 \leq N \leq 1\,000\,000$

예제 입력 1

9

예제 출력 1

6
  • Step 1: C → Copy A
  • Step 2: P → Screen = AA
  • Step 3: P → Screen = AAA
  • Step 4: C → Copy AAA
  • Step 5: P → Screen = AAAAAA
  • Step 6: P → Screen = AAAAAAAAA

Total steps = 6.

This example satisfies the conditions of Subtask 1 and 2.

예제 입력 2

1

예제 출력 2

0

This example satisfies the conditions of Subtask 1 and 2.

출처

University > 서강대학교 > CSE4152 문제해결프로그래밍실습 > 2025-2학기 중간고사 코딩 테스트 1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.