#B4029. Seed Growth Challenge
Seed Growth Challenge
Seed Growth Challenge
A seed is planted with an initial growth value of 0. After each day, if the seed's growth value reaches or exceeds \(k\), it is considered to have broken through the soil.
Starting from day \(1\), the seed grows. On day \(i\), the seed's growth value increases by \(\lfloor \frac{i}{w} \rfloor\). However, beginning on day \(x\) (inclusive), due to various external factors, it receives an additional \(y\) growth each day.
Please determine the day on which the seed breaks through the soil (i.e. the first day after which the cumulative growth is at least \(k\)).
Note: \(\lfloor x \rfloor\) denotes the greatest integer less than or equal to \(x\). For instance, \(\lfloor 2.5 \rfloor = 2\). In C++ the expression \(\lfloor \frac{i}{w} \rfloor\) can be computed as int(i/w)
.
inputFormat
The input consists of a single line containing four integers: \(k\), \(w\), \(x\), and \(y\), where:
- \(k\) is the threshold growth value that the seed must reach or exceed.
- \(w\) is the divisor used to compute the daily growth as \(\lfloor\frac{i}{w}\rfloor\).
- \(x\) is the day from which an additional growth of \(y\) is provided. (Day \(x\) and onwards)
- \(y\) is the additional daily growth starting from day \(x\).
outputFormat
Output a single integer representing the day on which the seed's growth value becomes greater than or equal to \(k\) after the day's growth.
sample
10 3 5 2
7