#abc210a. A - Cabbages

A - Cabbages

Score : 100100 points

问题描述

高桥正在访问一家专门卖白菜的商店。

该商店以每颗白菜 XX 日元(日本货币)的价格出售。
但是,如果你一次性购买超过 AA 颗白菜,则第 (A+1)(A+1) 颗及以后的白菜将以每颗 YY 日元的价格出售。
(保证 Y<XY \lt X。参考样例输入/输出 1 以获取清晰理解。)

打印出购买 NN 颗白菜所需的金额。

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

Problem Statement

Takahashi is visiting a shop specializing in cabbage.

The shop sells cabbage for XX yen (Japanese currency) per head.
However, if you buy more than AA heads of cabbage at once, the (A+1)(A+1)-th and subsequent heads will be sold for YY yen per head.
(It is guaranteed that Y<XY \lt X. See Sample Input/Output 1 for clarity.)

Print the amount of money needed to buy NN heads of cabbage.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1A1051 \leq A \leq 10^5
  • 1Y<X1001 \leq Y \lt X \leq 100
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN AA XX YY

Output

Print the amount of money needed to buy NN heads of cabbage (as an integer).

Sample Input 1

5 3 20 15

Sample Output 1

90

You need to pay 2020 yen for each of the 11-st through 33-rd heads of cabbage, and 1515 yen for each of the 44-th and 55-th heads of cabbage.
Thus, you need to pay a total of 20+20+20+15+15=9020+20+20+15+15 = 90 yen for the 55 heads of cabbage.

Sample Input 2

10 10 100 1

Sample Output 2

1000

update @ 2024/3/10 09:23:56