#abc265a. A - Apple

A - Apple

Score : 100100 points

问题描述

一家水果店销售苹果。 你可以按任意顺序进行以下操作,次数不限:

  • 花费 XX 日元购买一个苹果(日本货币)。
  • 花费 YY 日元购买三个苹果。

为了精确获得 NN 个苹果,你需要支付多少日元?

以上为通义千问 qwen-max 翻译,仅供参考。

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 XX yen (the currency in Japan).
  • Buy three apples for YY yen.

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

Constraints

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

Input

Input is given from Standard Input in the following format:

XX YY NN

Output

Print the answer as an integer.

Sample Input 1

10 25 10

Sample Output 1

85

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

Sample Input 2

10 40 10

Sample Output 2

100

It is optimal to buy an apple for 1010 yen 1010 times.

Sample Input 3

100 100 2

Sample Output 3

200

The only way to obtain exactly 22 apples is to buy an apple for 100100 yen twice.

Sample Input 4

100 100 100

Sample Output 4

3400

update @ 2024/3/10 11:11:20