TITLE: Question about swindler-writer
QUESTION [8 upvotes]: This question arose from my curiosity.
In one particular publishing house writer's salary depends on the amount of text he produces $-$ $p=20$ dollars for $s=1800$ symbols.
How much money can earn a swindler-writer by pressing $n=40$ buttons on the keyboard?
Writer can use Ctrl+C, Ctrl+V and Ctrl+A, but he can't copy text from other sources. 
For example combination Ctrl+A Ctrl+C Ctrl+V changes nothing in text, but you waste $6$ "pressings" of buttons. Meanwhile combination Ctrl+A Ctrl+C Ctrl+V Ctrl+V doubles amount of text.
I think the best way is to type a small text, and then several times perform the following procedure: select all via Ctrl+A and copy-paste several times. The problem is to determine amount procedures and amounts of times which he should copy-paste at each procedure.
I'm also interested in solution for arbitrary values of $n$,$s$,$p$, but I think it is too hard.

REPLY [6 votes]: It turns out that for $40$ button presses the maximum number of characters is $300$ (worth about $3.33), which can be achieved a number of different ways.
The recursion is $$f(n)= \max \{\,f(n-1)+1, \max_j \{j \times f(n-4-2j)\}\,\}$$ starting with $f(0)=0$ since you can type an extra character or do Ctrl-A, Ctrl-C and then Ctrl-V $j$ times. 
For $n=40$, possibilities are 

abcdefghij Ctrl-A Ctrl-C Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-A Ctrl-C Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-V by typing $10$ characters and then multiplying by $5$ (14 keystrokes)  and then by $6$  (16 keystrokes)  
abcdefghij Ctrl-A Ctrl-C Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-A Ctrl-C Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-V  by typing $10$ characters and then multiplying by $6$  (16 keystrokes)  and then by $5$  (14 keystrokes) 
abcdefghijkl Ctrl-A Ctrl-C Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-A Ctrl-C Ctrl-V Ctrl-V Ctrl-V Ctrl-V Ctrl-V  by typing $12$ characters and then multiplying by $5$  (14 keystrokes)  and then by $5$  (14 keystrokes) 

Added
For large $n$ we are interested in how much exponential growth is provided by multiplying by $j$ using $4+2j$ keystrokes, in effect multiplying by $j^{1/(4+2j)}$ each keystroke; for real $j$ this is maximised by $j \approx 4.319$, but for integer $j$ by $j = 4$ in which case $f(n)=4f(n-12)$, and this turns out to apply when $n \ge 67$.  So in the long run, the optimal answer is to keep multiplying by $4$ by using $12$ keystrokes 
Indeed for $n \ge 67$ we have $f(n)= k \times 2^{n/6}$ where $k$ depends on the remainder after dividing $n$ by $12$ and the various $k$ lie in the range $(3.05,3.182)$.
For example if $n$ is a multiple of $12$ then $k=\frac{25}{8}=3.125$ and we can say $f(12m)=50 \times 4^{m-2}$ for integer $m\ge 2$.  To get this, type $10$ characters, a multiplication by $5$ and $m-2$ multiplications by $4$; it does not matter when the multiplication by $5$ happens in the multiplications by $4$.