Problem9807--ABC265 —— A - Apple

9807: ABC265 —— A - Apple

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

A fruit store sells apples.  
You may perform the following operations as many times as you want in any order:

-   Buy one apple for $X$ yen (the currency in Japan).
-   Buy three apples for $Y$ yen.

How much yen do you need to pay to obtain exactly $N$ apples?

Input

Input is given from Standard Input in the following format:

```
$X$ $Y$ $N$
```

Output

Print the answer as an integer.

Constraints

-   $1 \leq X \leq Y \leq 100$
-   $1 \leq N \leq 100$
-   All values in input are integers.

Sample 1 Input

10 25 10

Sample 1 Output

85
Buy three apples for 25 yen three times and one apple for 10 yen, and you will obtain exactly 10 apples for a total of 85 yen.
You cannot obtain exactly 10 apples for a lower cost, so the answer is 85 yen.

Sample 2 Input

10 40 10

Sample 2 Output

100
It is optimal to buy an apple for 10 yen 10 times.

Sample 3 Input

100 100 2

Sample 3 Output

200
The only way to obtain exactly 2 apples is to buy an apple for 100 yen twice.

100 100 100

3400

Source/Category