QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB

#23974. Apple

Statistics

問題文

JOI 君はリンゴを買おうとしている.

リンゴを 1 個買うと X 円である.またリンゴを 2 個のセットで買うと,1 個 Y 円で (1 セットでは 2Y 円で) 買うことができる.ここで Y < X が成り立つ.

1 個と 2 個のセットを組み合わせて,リンゴを合計でちょうど N 個買うとき,支払う金額の最小値を求めよ.

制約

  • 1 ≦ X ≦ 100.
  • 1 ≦ Y ≦ 100.
  • 1 ≦ N ≦ 100.
  • Y < X.
  • 入力される値はすべて整数である.

入力

入力は以下の形式で与えられる.
X Y N

出力

リンゴを合計でちょうど N 個買うときの支払う金額の最小値を,単位 (円) を除いて出力せよ.

答え以外は何も出力しないこと.(入力を促す文章なども出力しないこと.)

解答形式については,練習問題やその解答例を参考にしても良い.


入力例 1

4   3   5

出力例 1

16

リンゴを 4 円で 1 個買い,2 個のセットを 2 セット (計 2 × 2 = 4 個) 買うと,合計で 4 × 1 + 3 × 4 = 16 円となる.他の買い方では,これより安く買うことはできないため,16 を出力する.


入力例 2

3   1   6

出力例 2

6

2 個のセットを 3 セット買うのが最も安い.したがって合計で 1 × 2 × 3 = 6 円となる.


入力例 3

10   2   1

出力例 3

10

10 円で 1 個買うため,合計で 10 × 1 = 10 円となる.ここでリンゴは合計でちょうど N 個買う必要があるため,2 × 2 = 4 円で余分に 2 個セットを買うことはできないことに注意せよ.

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.