Problems
Bessie likes to watch shows on Mooloo. Because Bessie is a busy cow, she has planned a schedule for the next
Mooloo has an interesting subscription system: it costs
Input
The first line contains integers
The second line contains
Output
Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).
Example #1
2 4
7 9
7
Bessie buys a three-day subscription on day 7, spending d+K=3+4=7 moonies.
Example #2
2 3
1 10
8
Bessie first buys a one-day subscription on day 1, spending d+K=1+3=4 moonies. Bessie also buys a one-day subscription on day 10, spending d+K=1+3=4 moonies. In total, Bessie spends 8 moonies.