#P8822. Calculate Total Tuition from Dynamic Course Pricing
Calculate Total Tuition from Dynamic Course Pricing
Calculate Total Tuition from Dynamic Course Pricing
In this problem, you are given a course that follows a dynamic pricing strategy. Initially, the course is priced at \(v\) yuan. For every \(m\) students who register, the course price increases by \(a\) yuan. The registration is open until \(n\) students have enrolled. Your task is to calculate the total tuition fee collected when the registration closes.
More formally, the price for the \(i\)-th student (1-indexed) is given by:
[ \text{price}_i = v + a \times \left\lfloor \frac{i-1}{m} \right\rfloor ]
You need to output the sum:
[ \text{Total Tuition} = \sum_{i=1}^{n} \left(v + a \times \left\lfloor \frac{i-1}{m} \right\rfloor\right). ]
</p>inputFormat
The input consists of a single line containing four space-separated integers:
v
: the initial price of the course in yuan,m
: the number of students after which the course price increases,a
: the amount by which the price increases after everym
students register,n
: the maximum number of students allowed to register.
outputFormat
Output a single integer representing the total tuition fee collected when the registration stops.
sample
100 10 10 100
14500