Universal Cup Judging System

Universal Cup

Time Limit: 1.0 s Memory Limit: 1024 MB Total points: 100
Statistics

John 非常重視安全,因此他的密碼非常長:它有 $n$ 個字元。然而,他並沒有什麼創意,所以密碼中的所有字元都是相同的——字母 a。John 非常沒有耐心,因此他希望盡可能快地輸入密碼。

他希望得到一個恰好由 $n$ 個字母 a 組成的字串。他可以使用以下操作序列:「a」(輸入字母 a)、「Ctrl-A」(全選)、「Ctrl-C」(複製到剪貼簿)、「Ctrl-V」(從剪貼簿貼上)。當從空的密碼輸入框與空的剪貼簿開始時,達到目標結果所需的最少操作次數是多少?

以下是 John 在密碼輸入框中可以執行的四種操作的精確定義:

  • 按下「a」:如果未選取任何文字,則在游標位置插入字母 a(插入到游標左側)。否則,用字母 a 取代選取的文字。之後,沒有文字被選取,且游標位於密碼輸入框的末尾。
  • 按下「Ctrl-A」:選取密碼輸入框中的所有文字。
  • 按下「Ctrl-C」:如果未選取任何文字,則什麼都不做。否則,將選取的文字複製到剪貼簿。
  • 按下「Ctrl-V」:如果剪貼簿為空,則什麼都不做。否則,如果未選取任何文字,則在游標位置插入剪貼簿中的文字(插入到游標左側)。否則,用剪貼簿中的文字取代選取的文字。最後,沒有文字被選取,且游標位於密碼輸入框的末尾。剪貼簿的內容不會改變。

輸入格式

輸入的第一行,也是唯一的一行,包含一個整數 $n$($1 \le n \le 10^{12}$),表示期望的密碼長度。

輸出格式

輸出一個整數,表示輸入期望長度的密碼所需的最少操作次數。

範例

輸入

11

輸出

10

說明

John 可以使用以下操作序列:a, a, Ctrl-A, Ctrl-C, Ctrl-V, Ctrl-V, Ctrl-V, Ctrl-V, Ctrl-V, a。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1051EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.