#P5810. Minimum Time to Generate Text
Minimum Time to Generate Text
Minimum Time to Generate Text
You are given an integer n. Initially the text is empty, and you want to generate a text with a length of at least n characters. There are three operations available:
- Type a single letter at a cost of $1$.
- Copy the entire current text to the clipboard at a cost of $5$ (this operation is equivalent to pressing Ctrl+A, Ctrl+C, and then deselecting the text).
- Paste the entire content of the clipboard at the end of the text at a cost of $2$.
Note that if you use the copy operation when you have i characters, you can then paste repeatedly. After copying, every paste appends exactly i characters. Formally, if you are at a state with i characters, and you decide to copy (cost $5$) and then paste k times (each paste costs $2$, so total paste cost is $2k$), then the text length becomes i × (k+1) and the total additional cost is $5+2k$.
Your task is to find the minimum total time required to obtain a text of length at least n.
Note: The data range in this problem is slightly different from the original version.
inputFormat
The input consists of a single integer n (where n ≥ 1), representing the minimum length of the text.
outputFormat
Output a single integer, the minimum time required to generate a text of length at least n.
sample
1
1