题目描述
Problem Description
The Takahashi family has decided to buy \( K \) oranges for the current season. Oranges are sold for \( A \) yen each, and also in sets of \( L \) oranges for \( B \) yen. Write a program to determine the minimum amount of money needed to buy at least \( K \) oranges by purchasing a combination of individual oranges and sets of \( L \) oranges.
Input Format
The input is given from the standard input in the following format:
\( A \) \( B \) \( K \) \( L \)
Output Format
Output the minimum amount of money required to buy at least \( K \) oranges.
Sample Input and Output
Sample Input #1
3 7 10 3
Sample Output #1
24
Sample Input #2
4 5 11 3
Sample Output #2
20
Sample Input #3
3 8 3 3
Sample Output #3
8
Sample Input #4
3 8 2 3
Sample Output #4
6
Notes/Hints
Constraints
- \( 1 \leq A, B, K \leq 10^9 \)
- \( 2 \leq L \leq 10^9 \)
- \( B \leq A \times L \)
Sample Explanation 1
Buying 3 sets of 3 oranges and 1 individual orange totals 24 yen. There is no cheaper way to buy 10 oranges.
Sample Explanation 2
The optimal solution is to buy 4 sets of 3 oranges.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分