QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 1024 MB

#23974. Apple

통계

Problem Statement

JOI-kun is about to buy apples.

Buying $1$ apple costs $X$ yen. Also, when buying apples in a set of $2$, they can be bought at $Y$ yen per $1$ apple ($2Y$ yen per $1$ set). Here, $Y < X$ holds.

When buying a total of exactly $N$ apples by combining individual $1$-apple purchases and sets of $2$ apples, find the minimum amount of money to pay.

Constraints

  • $1 \le X \le 100$.
  • $1 \le Y \le 100$.
  • $1 \le N \le 100$.
  • $Y < X$.
  • All input values are integers.

Input

The input is given in the following format:

X Y N

Output

Output the minimum amount of money to pay when buying a total of exactly $N$ apples, omitting the unit (yen).

Do not output anything other than the answer. (Do not output sentences prompting for input, etc.)

For the output format, you may also refer to Practice Problems and Their Sample Solutions.


Sample Input $1$

4 3 5

Sample Output $1$

16

If he buys $1$ apple for $4$ yen and buys $2$ sets of $2$ apples ($2 \times 2 = 4$ apples in total), the total cost is $4 \times 1 + 3 \times 4 = 16$ yen. Since it is impossible to buy them cheaper with any other way of buying, output $16$.


Sample Input $2$

3 1 6

Sample Output $2$

6

Buying $3$ sets of $2$ apples is the cheapest. Therefore, the total cost is $1 \times 2 \times 3 = 6$ yen.


Sample Input $3$

10 2 1

Sample Output $3$

10

Since he buys $1$ apple for $10$ yen, the total cost is $10 \times 1 = 10$ yen. Note here that because he must buy a total of exactly $N$ apples, he cannot buy an extra set of $2$ apples for $2 \times 2 = 4$ yen.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.