100 atcoder#ABC210A. [ABC210A] Cabbages
[ABC210A] Cabbages
Score : points
Problem Statement
Takahashi is visiting a shop specializing in cabbage.
The shop sells cabbage for yen (Japanese currency) per head. However, if you buy more than heads of cabbage at once, the -th and subsequent heads will be sold for yen per head. (It is guaranteed that . See Sample Input/Output 1 for clarity.)
Print the amount of money needed to buy heads of cabbage.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the amount of money needed to buy heads of cabbage (as an integer).
5 3 20 15
90
You need to pay yen for each of the -st through -rd heads of cabbage, and yen for each of the -th and -th heads of cabbage. Thus, you need to pay a total of yen for the heads of cabbage.
10 10 100 1
1000