No.555 World History Report
タグ : / 解いたユーザー数 180
作問者 :
addeight2
/ テスター :
butsurizuki
Problem Statement
addeight is a high school student.
He is now writing a world history report on his computer.
However, he is bad at world history, and so far the report contains only the letter A.
If the report does not contain at least \(N\) characters, the scary world history teacher will get angry at him.
So, addeight decided to create a string of at least \(N\) characters using only copy and paste.
Copying copies the entire string of the report to the clipboard, and pasting appends the string in the clipboard to the end of the string of the report.
Copy and paste cost \(C\) and \(V\), respectively. Find the minimum cost to create at least \(N\) characters.
The clipboard is initially an empty string.
Input
N C V
\(2 \leq N \leq 50000\)
\(1 \leq C , V \leq 1000\)
Output
Output the minimum cost required to create at least \(N\) characters.
Print a newline at the end.
Sample
Sample 1
Input
6 3 2
Output
12
| Operation | String in the report | String in the clipboard |
|---|---|---|
| Initial state | A | |
| Copy | A | A |
| Paste | AA | A |
| Copy | AA | AA |
| Paste | AAAA | AA |
| Paste | AAAAAA | AA |
Sample 2
Input
10 1 3
Output
15
The sequence copy, paste, copy, paste, copy, paste, paste creates 12 characters at a cost of 15. There are also other ways to create at least 10 characters at a cost of 15.
Sample 3
Input
100 1000 1
Output
1099
Copy once, then paste 99 times.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。