P5810 [SCOI2004] Text Input

Description

When people input text, besides typing character by character, they can also use the clipboard to copy. Typing one letter takes $1$ unit of time. Copying the part that has already been typed into the clipboard takes $5$ units of time (`Ctrl`+`A`, `Ctrl`+`C`, then cancel the select-all state). Pasting the clipboard content takes $2$ units of time (`Ctrl`+`V`). If we do not care about the actual content of the text and only care about its length, what is the minimum time needed to input a text whose length is **at least** $n$? **Note: The Constraints are slightly different from the original problem.**

Input Format

A positive integer $n$, representing the length of the text.

Output Format

A positive integer $t$, representing the minimum time needed.

Explanation/Hint

Sample explanation: First spend $7$ units of time to type $7$ characters, then copy (costs $5$ units of time), paste twice (costs $4$ units of time), and you can type $21$ characters in $16$ units of time. For $20\%$ of the testdata, $n\le 10$. For $60\%$ of the testdata, $n\le 10^4$. For $100\%$ of the testdata, $n\le 4\times 10^4$. Translated by ChatGPT 5