102650: [AtCoder]ABC265 A - Apple

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $100$ points

Problem Statement

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?

Constraints

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

Input

Input is given from Standard Input in the following format:

$X$ $Y$ $N$

Output

Print the answer as an integer.


Sample Input 1

10 25 10

Sample Output 1

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 Input 2

10 40 10

Sample Output 2

100

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


Sample Input 3

100 100 2

Sample Output 3

200

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


Sample Input 4

100 100 100

Sample Output 4

3400

Input

题意翻译

你需要买 $N$ 个苹果,买 $1$ 个需要 $X$ 元,买 $3$ 个需要 $Y$ 元。问至少需要几元可以买到 $N$ 个苹果。

Output

分数:100分

问题描述

一家水果店出售苹果。

你可以按照任何顺序想买多少次就买多少次以下操作:

  • 以X日元(日本货币)的价格买一个苹果。
  • 以Y日元的价格买三个苹果。

你需要支付多少日元才能获得正好 N 个苹果?

约束

  • $1 \leq X \leq Y \leq 100$
  • $1 \leq N \leq 100$
  • 输入中的所有值都是整数。

输入

输入格式如下,从标准输入中给出:

$X$ $Y$ $N$

输出

以整数形式打印答案。


样例输入 1

10 25 10

样例输出 1

85

以25日元的价格购买3个苹果3次,然后以10日元的价格购买1个苹果,总共用85日元就可以获得正好10个苹果。 你不能以更低的成本获得正好10个苹果,所以答案是85日元。


样例输入 2

10 40 10

样例输出 2

100

购买10次10日元的苹果是最佳选择。


样例输入 3

100 100 2

样例输出 3

200

获得正好 2个苹果的唯一方法是购买两次100日元的苹果。


样例输入 4

100 100 100

样例输出 4

3400

加入题单

算法标签: