No.1862 Copy and Paste
タグ : / 解いたユーザー数 46
作問者 :
ぷら
shiomusubi496
Problem Statement
Chipppppp wants to increase the number of characters p.
Currently, the string $S$ is the single character p, and the string $T$ is the empty string.
Chipppppp can perform the following two operations any number of times:
- Operation A: Replace $T$ with $S$. This takes $A$ seconds.
- Operation B: Append $T$ to the end of $S$. This takes $B$ seconds.
Find the minimum time required to make $S$ have at least $N$ characters.
Input
$A$ $B$ $N$
Output
Output the minimum time required to make $S$ have at least $N$ characters. Also, output a newline at the end.
Sample
Sample 1
Input
1 1 10
Output
7
Here is one example of a sequence of operations.
- Perform operation A. $S$ becomes
pand $T$ becomesp. - Perform operation B. $S$ becomes
ppand $T$ becomesp. - Perform operation A. $S$ becomes
ppand $T$ becomespp. - Perform operation B. $S$ becomes
ppppand $T$ becomespp. - Perform operation B. $S$ becomes
ppppppand $T$ becomespp. - Perform operation A. $S$ becomes
ppppppand $T$ becomespppppp. - Perform operation B. $S$ becomes
ppppppppppppand $T$ becomespppppp.
Since operation A is performed $3$ times and operation B is performed $4$ times, this takes $1 \times 3 + 1 \times 4 = 7$ seconds, so $7$ seconds. It is impossible to make the string $S$ have at least $10$ characters in $6$ seconds or less, so output $7$.
Sample 2
Input
1000 100 1
Output
0
No operations need to be performed.
Sample 3
Input
3 2 20
Output
20
Sample 4
Input
33 4 74089
Output
334
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。